Skip to content

Commit 5a36024

Browse files
authored
Merge branch 'main' into useSymlink
2 parents 38fc859 + 936d048 commit 5a36024

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+4039
-314
lines changed

.github/workflows/compile-examples.yml

+24-14
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,26 @@ jobs:
3838
- libraries/RTC/examples/Test_RTC
3939
- libraries/SoftwareSerial
4040
- libraries/WDT
41+
SKETCHES_REPORTS_PATH: sketches-reports
4142

4243
strategy:
4344
fail-fast: false
4445

4546
matrix:
46-
board: [
47-
{"fqbn": "arduino:renesas_portenta:portenta_c33"},
48-
{"fqbn": "arduino:renesas_uno:minima"},
49-
{"fqbn": "arduino:renesas_uno:unor4wifi"},
50-
{"fqbn": "arduino-git:renesas:portenta_c33"},
51-
{"fqbn": "arduino-git:renesas:minima"},
52-
{"fqbn": "arduino-git:renesas:unor4wifi"},
53-
]
47+
board:
48+
- fqbn: arduino:renesas_portenta:portenta_c33
49+
id: c33
50+
- fqbn: arduino:renesas_uno:minima
51+
id: minima
52+
- fqbn: arduino:renesas_uno:unor4wifi
53+
id: wifi
54+
- fqbn: arduino-git:renesas:portenta_c33
55+
id: git_c33
56+
- fqbn: arduino-git:renesas:minima
57+
id: git_minima
58+
- fqbn: arduino-git:renesas:unor4wifi
59+
id: git_wifi
60+
5461

5562
# make board type-specific customizations to the matrix jobs
5663
include:
@@ -69,6 +76,7 @@ jobs:
6976
- libraries/RTC/examples/RTC_NTPSync
7077
- libraries/RTC/examples/RTC_Alarm
7178
- libraries/SFU
79+
- libraries/KVStore/examples/StartCounter
7280
- board:
7381
fqbn: "arduino-git:renesas:portenta_c33"
7482
additional-sketch-paths: |
@@ -84,6 +92,7 @@ jobs:
8492
- libraries/RTC/examples/RTC_NTPSync
8593
- libraries/RTC/examples/RTC_Alarm
8694
- libraries/SFU
95+
- libraries/KVStore/examples/StartCounter
8796
- board:
8897
fqbn: "arduino:renesas_uno:unor4wifi"
8998
additional-sketch-paths: |
@@ -106,11 +115,11 @@ jobs:
106115
107116
steps:
108117
- name: Checkout repository
109-
uses: actions/checkout@v3
118+
uses: actions/checkout@v4
110119

111120
# The source files are in a subfolder of the ArduinoCore-API repository, so it's not possible to clone it directly to the final destination in the core
112121
- name: Checkout ArduinoCore-API
113-
uses: actions/checkout@v3
122+
uses: actions/checkout@v4
114123
with:
115124
repository: arduino/ArduinoCore-API
116125
path: extras/ArduinoCore-API
@@ -125,7 +134,7 @@ jobs:
125134
if: steps.checkapi.outputs.IS_API == 'true'
126135

127136
- name: Checkout Basic examples
128-
uses: actions/checkout@v3
137+
uses: actions/checkout@v4
129138
with:
130139
repository: arduino/arduino-examples
131140
path: examples
@@ -173,9 +182,10 @@ jobs:
173182
enable-deltas-report: 'false'
174183
verbose: 'true'
175184
github-token: ${{ secrets.GITHUB_TOKEN }}
185+
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
176186

177187
- name: Save memory usage change report as artifact
178-
uses: actions/upload-artifact@v3
188+
uses: actions/upload-artifact@v4
179189
with:
180-
name: sketches-reports
181-
path: sketches-reports
190+
path: ${{ env.SKETCHES_REPORTS_PATH }}
191+
name: sketches-reports-${{ matrix.board.id }}

boards.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ portenta_c33.build.fpu=-mfpu=fpv5-sp-d16
1212
portenta_c33.build.float-abi=-mfloat-abi=hard
1313

1414
portenta_c33.build.board=PORTENTA_C33
15-
portenta_c33.build.defines=-DF_CPU=200000000 -DPROVIDE_FREERTOS_HOOK
15+
portenta_c33.build.defines=-DF_CPU=200000000
1616
portenta_c33.vid.0=0x2341
1717
portenta_c33.pid.0=0x0068
1818
portenta_c33.vid.1=0x2341

cores/arduino/analog.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,10 @@ void analogReference(uint8_t mode) {
558558
R_ADC_Open(&adc1.ctrl, &adc1.cfg);
559559
}
560560

561+
#if defined(AVCC_MEASURE_PIN)
561562
static float aref = 0;
563+
#endif
564+
562565
float analogReference() {
563566
switch (adc.cfg_extend.adc_vref_control) {
564567
case ADC_VREF_CONTROL_1_5V_OUTPUT:
@@ -642,7 +645,7 @@ void analogReadResolution(int bits) {
642645
default:
643646
_analogRequestedReadResolution = 12;
644647
adc.cfg.resolution = ADC_RESOLUTION_12_BIT;
645-
adc1.cfg.resolution = ADC_RESOLUTION_10_BIT;
648+
adc1.cfg.resolution = ADC_RESOLUTION_12_BIT;
646649
break;
647650
}
648651

@@ -817,4 +820,4 @@ void analogWrite(pin_size_t pinNumber, int value)
817820

818821
FspTimer* __get_timer_for_channel(int channel) {
819822
return pwms.get_from_channel(channel)->get_timer();
820-
}
823+
}

cores/arduino/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ void unsecure_registers() {
6565

6666
extern "C" void Stacktrace_Handler(void);
6767
extern "C" __attribute__((weak)) void start_freertos_on_header_inclusion() {}
68+
extern "C" __attribute__((weak)) void early_start_freertos_on_header_inclusion() {}
6869

6970
void arduino_main(void)
7071
{
@@ -112,10 +113,9 @@ void arduino_main(void)
112113
Serial.begin(115200);
113114
#endif
114115
startAgt();
116+
early_start_freertos_on_header_inclusion();
115117
setup();
116-
#ifdef PROVIDE_FREERTOS_HOOK
117118
start_freertos_on_header_inclusion();
118-
#endif
119119
while (1)
120120
{
121121
loop();

extras/net/lwipopts.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@
277277
* (requires the LWIP_RAW option)
278278
*/
279279
#ifndef MEMP_NUM_RAW_PCB
280-
#define MEMP_NUM_RAW_PCB 0
280+
#define MEMP_NUM_RAW_PCB 1
281281
#endif
282282

283283
/**
@@ -642,7 +642,7 @@
642642
* LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
643643
*/
644644
#ifndef LWIP_RAW
645-
#define LWIP_RAW 0
645+
#define LWIP_RAW 1
646646
#endif
647647

648648
/*

libraries/Arduino_FreeRTOS/src/Arduino_FreeRTOS.h

+21
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ extern "C" {
2727
#include "lib/FreeRTOS-Kernel-v10.5.1/semphr.h"
2828
#include "lib/FreeRTOS-Kernel-v10.5.1/task.h"
2929
#include "lib/FreeRTOS-Kernel-v10.5.1/timers.h"
30+
#include <stdbool.h>
31+
32+
33+
// If you need to automatically start FREERTOS, declare either EARLY_AUTOSTART_FREERTOS or
34+
// AUTOSTART_FREERTOS in your library or sketch code (.ino or .cpp file)
35+
//
36+
// EARLY_AUTOSTART_FREERTOS -> if you need the scheduler to be already running in setup()
37+
// AUTOSTART_FREERTOS -> if you only declare the threads in setup() and use them in loop()
38+
39+
void _start_freertos_on_header_inclusion_impl(bool early_start);
40+
void early_start_freertos_on_header_inclusion();
41+
void start_freertos_on_header_inclusion();
42+
#define EARLY_AUTOSTART_FREERTOS \
43+
void early_start_freertos_on_header_inclusion() { \
44+
_start_freertos_on_header_inclusion_impl(true); \
45+
}
46+
#define AUTOSTART_FREERTOS \
47+
void start_freertos_on_header_inclusion() { \
48+
_start_freertos_on_header_inclusion_impl(false); \
49+
}
50+
3051

3152
#ifdef __cplusplus
3253
}

libraries/Arduino_FreeRTOS/src/portable/FSP/port.c

+22-15
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "FreeRTOSConfig.h"
3333
#include "../../lib/FreeRTOS-Kernel-v10.5.1/FreeRTOS.h"
3434
#include "../../lib/FreeRTOS-Kernel-v10.5.1/task.h"
35+
#include "portmacro.h"
3536

3637
#if BSP_TZ_NONSECURE_BUILD
3738
#include "tz_context.h"
@@ -225,28 +226,34 @@ static void prvTaskExitError(void);
225226

226227
#endif
227228

228-
#ifdef PROVIDE_FREERTOS_HOOK
229-
void loop_thread_func(void* arg) {
229+
extern void setup(void);
230+
extern void loop(void);
231+
232+
static void sketch_thread_func(void* arg) {
233+
bool early_start = (bool)arg;
234+
if (early_start) {
235+
setup();
236+
}
230237
while (1)
231238
{
232239
loop();
233240
}
234241
}
235242

236-
static TaskHandle_t loop_task;
237-
void start_freertos_on_header_inclusion() {
238-
xTaskCreate(
239-
(TaskFunction_t)loop_thread_func,
240-
"Loop Thread",
241-
4096 / 4, /* usStackDepth in words */
242-
NULL, /* pvParameters */
243-
4, /* uxPriority */
244-
&loop_task /* pxCreatedTask */
245-
);
246-
247-
vTaskStartScheduler();
243+
void _start_freertos_on_header_inclusion_impl(bool early_start) {
244+
static TaskHandle_t sketch_task;
245+
if (xTaskGetSchedulerState() != taskSCHEDULER_RUNNING) {
246+
xTaskCreate(
247+
(TaskFunction_t)sketch_thread_func,
248+
"Sketch Thread",
249+
4096 / 4, /* usStackDepth in words */
250+
(void*)early_start, /* pvParameters */
251+
4, /* uxPriority */
252+
&sketch_task /* pxCreatedTask */
253+
);
254+
vTaskStartScheduler();
255+
}
248256
}
249-
#endif
250257

251258
/* Arduino specific overrides */
252259
void delay(uint32_t ms) {

libraries/BlockDevices/QSPIFlashBlockDevice.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ int QSPIFlashBlockDevice::write(const void *buffer, bd_addr_t add, bd_size_t _si
287287
R_QSPI_BankSet(&ctrl, bank);
288288
rv = R_QSPI_Write(&ctrl, (uint8_t *)(buffer), (uint8_t*)address, chunk);
289289
address += chunk;
290-
buffer += chunk;
290+
buffer = (uint8_t *)(buffer) + chunk;
291291

292292
if(rv == FSP_SUCCESS) {
293293
rv = get_flash_status();
@@ -328,7 +328,7 @@ int QSPIFlashBlockDevice::erase(bd_addr_t add, bd_size_t _size) {
328328

329329
uint32_t num_of_blocks = (_size / erase_block_size);
330330

331-
for(int i = 0; i < num_of_blocks && rv == FSP_SUCCESS; i++) {
331+
for(uint32_t i = 0; i < num_of_blocks && rv == FSP_SUCCESS; i++) {
332332
/* set bank */
333333
uint32_t bank = add / READ_PAGE_SIZE;
334334
uint32_t address = base_address + ((add + i * erase_block_size) % READ_PAGE_SIZE);

libraries/BlockDevices/QSPIFlashBlockDevice.h

+10-8
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,27 @@
7070

7171
class QSPIFlashBlockDevice : public BlockDevice {
7272
private:
73-
bool opened;
74-
73+
74+
pin_t ck;
75+
pin_t cs;
76+
pin_t io0;
77+
pin_t io1;
78+
pin_t io2;
79+
pin_t io3;
80+
7581
bd_addr_t base_address;
7682
bd_size_t total_size;
7783
bd_size_t read_block_size;
7884
bd_size_t erase_block_size;
7985
bd_size_t write_block_size;
8086

87+
bool opened;
88+
8189
bool is_address_correct(bd_addr_t add);
8290

8391
qspi_instance_ctrl_t ctrl;
8492
spi_flash_cfg_t cfg;
8593
qspi_extended_cfg_t ext_cfg;
86-
pin_t ck;
87-
pin_t cs;
88-
pin_t io0;
89-
pin_t io1;
90-
pin_t io2;
91-
pin_t io3;
9294

9395
fsp_err_t get_flash_status();
9496

libraries/BlockDevices/SDCardBlockDevice.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ SDCardBlockDevice::~SDCardBlockDevice() {
166166
/* CALLBACK */
167167
/* -------------------------------------------------------------------------- */
168168
void SDCardBlockDevice::SDCardBlockDeviceCbk(sdmmc_callback_args_t *arg) {
169-
int open_status = -1;
170169
if(arg != nullptr) {
171170
sdmmc_event_t event = arg->event;
172171

@@ -368,8 +367,9 @@ int SDCardBlockDevice::read(void *buffer, bd_addr_t add, bd_size_t _size) {
368367
uint32_t num_of_blocks = (_size / read_block_size);
369368
uint32_t start_add_of_block = (add / read_block_size);
370369
rv = FSP_SUCCESS;
371-
for(int i = 0; i < num_of_blocks && rv == FSP_SUCCESS; i++) {
372-
rv = R_SDHI_Read (&ctrl, (uint8_t *)(buffer + (i * read_block_size)), start_add_of_block + i, 1);
370+
for(uint32_t i = 0; i < num_of_blocks && rv == FSP_SUCCESS; i++) {
371+
uint8_t *buf = (uint8_t *)buffer;
372+
rv = R_SDHI_Read (&ctrl, buf + (i * read_block_size), start_add_of_block + i, 1);
373373
if(rv == FSP_SUCCESS) {
374374
rv = wait_for_completition();
375375
}
@@ -404,8 +404,9 @@ int SDCardBlockDevice::write(const void *buffer, bd_addr_t add, bd_size_t _size)
404404
uint32_t num_of_blocks = (_size / write_block_size);
405405
uint32_t start_block_number = (add / write_block_size);
406406
rv = FSP_SUCCESS;
407-
for(int i = 0; i < num_of_blocks && rv == FSP_SUCCESS; i++) {
408-
rv = R_SDHI_Write (&ctrl, (uint8_t *)(buffer + (i * write_block_size)), start_block_number + i, 1);
407+
for(uint32_t i = 0; i < num_of_blocks && rv == FSP_SUCCESS; i++) {
408+
uint8_t *buf = (uint8_t *)buffer;
409+
rv = R_SDHI_Write (&ctrl, buf + (i * write_block_size), start_block_number + i, 1);
409410
if(rv == FSP_SUCCESS) {
410411
rv = wait_for_completition();
411412
}
@@ -439,7 +440,7 @@ int SDCardBlockDevice::erase(bd_addr_t add, bd_size_t _size) {
439440
uint32_t num_of_blocks = (_size / erase_block_size);
440441
uint32_t start_block_number = (add / erase_block_size);
441442
rv = FSP_SUCCESS;
442-
for(int i = 0; i < num_of_blocks && rv == FSP_SUCCESS; i++) {
443+
for(uint32_t i = 0; i < num_of_blocks && rv == FSP_SUCCESS; i++) {
443444
rv = R_SDHI_Erase (&ctrl, start_block_number + i, 1);
444445
if(rv == FSP_SUCCESS) {
445446
rv = wait_for_completition();

libraries/BlockDevices/SDCardBlockDevice.h

+12-10
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,22 @@ enum class CmdStatus {
6060

6161
class SDCardBlockDevice : public BlockDevice {
6262
private:
63-
sdmmc_device_t sd_card_info;
63+
pin_t ck;
64+
pin_t cmd;
65+
pin_t d0;
66+
pin_t d1;
67+
pin_t d2;
68+
pin_t d3;
69+
pin_t cd;
70+
pin_t wp;
6471
bd_addr_t base_address;
6572
bd_size_t total_size;
6673
bd_size_t read_block_size;
6774
bd_size_t erase_block_size;
6875
bd_size_t write_block_size;
76+
bool opened;
6977
sdhi_instance_ctrl_t ctrl;
78+
sdmmc_device_t sd_card_info;
7079
sdmmc_cfg_t cfg;
7180

7281
#ifdef USE_DMAC
@@ -84,22 +93,15 @@ class SDCardBlockDevice : public BlockDevice {
8493
transfer_cfg_t dtc_cfg;
8594
transfer_instance_t dtc_instance;
8695
#endif
87-
pin_t ck;
88-
pin_t cmd;
89-
pin_t d0;
90-
pin_t d1;
91-
pin_t d2;
92-
pin_t d3;
93-
pin_t cd;
94-
pin_t wp;
96+
9597
static volatile bool initialized;
9698
static volatile bool card_inserted;
9799
static volatile CmdStatus st;
98100
static void SDCardBlockDeviceCbk(sdmmc_callback_args_t *);
99101
virtual int write(const void *buffer, bd_addr_t addr, bd_size_t size) override;
100102
virtual int open() override;
101103
virtual int close() override;
102-
bool opened;
104+
103105
fsp_err_t wait_for_completition();
104106
public:
105107

0 commit comments

Comments
 (0)