Skip to content

Commit 7802eed

Browse files
iabdalkaderdpgeorge
authored andcommitted
renesas-ra/boards/ARDUINO_PORTENTA_C33: Add support for Portenta C33.
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
1 parent abd9bed commit 7802eed

24 files changed

Lines changed: 2323 additions & 0 deletions

ports/renesas-ra/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ Linux, Mac and Windows hosts via https://developer.arm.com/downloads/-/arm-gnu-t
4040
The compiler can be changed using the `CROSS_COMPILE` variable
4141
when invoking `make`.
4242

43+
* Protocol buffer compiler
44+
Building for the `ARDUINO_PORTENTA_C33` board will build the `esp_hosted` driver, that depends
45+
on the Protocol Buffer Compiler being installed. On Debian/Ubuntu, this can be installed with
46+
`sudo apt-get install protobuf-compiler`.
47+
4348
* Obtain submodules
4449
First the submodules must be obtained using:
4550

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"deploy": [
3+
"./deploy.md"
4+
],
5+
"docs": "",
6+
"features": [
7+
"512KB SRAM",
8+
"2MB Flash",
9+
"16MB QSPI Flash",
10+
"USB High Speed Phy",
11+
"10/100 Ethernet Phy",
12+
"ESP32 WiFi/BT Module",
13+
"NXP SE050 crypto device"
14+
],
15+
"images": [
16+
"ABX00074_01.iso_1000x750.jpg"
17+
],
18+
"mcu": "RA6M5",
19+
"product": "Arduino Portenta C33",
20+
"thumbnail": "",
21+
"url": "https://store.arduino.cc/pages/portenta-c33",
22+
"vendor": "Arduino"
23+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2023 Arduino SA
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "py/mphal.h"
28+
#include "r_sce.h"
29+
30+
// Key code for writing PRCR register.
31+
#define BSP_PRV_PRCR_KEY (0xA500U)
32+
#define BSP_PRV_PRCR_PRC1_UNLOCK ((BSP_PRV_PRCR_KEY) | 0x2U)
33+
#define BSP_PRV_PRCR_LOCK ((BSP_PRV_PRCR_KEY) | 0x0U)
34+
#define BOOT_DOUBLE_TAP_DATA (0x07738135)
35+
#define BOOT_DOUBLE_TAP_ADDR (*((volatile uint32_t *)&R_SYSTEM->VBTBKR[0]))
36+
37+
void PORTENTA_C33_board_startup() {
38+
// Enable USB_BASE
39+
R_SYSTEM->PRCR = (uint16_t)BSP_PRV_PRCR_PRC1_UNLOCK;
40+
R_MSTP->MSTPCRB &= ~(1U << 11U);
41+
R_MSTP->MSTPCRB &= ~(1U << 12U);
42+
R_SYSTEM->PRCR = (uint16_t)BSP_PRV_PRCR_LOCK;
43+
44+
// Re-enable IRQs after jump from the bootloader.
45+
__enable_irq();
46+
}
47+
48+
void PORTENTA_C33_board_enter_bootloader(void) {
49+
R_SYSTEM->PRCR = (uint16_t)BSP_PRV_PRCR_PRC1_UNLOCK;
50+
BOOT_DOUBLE_TAP_ADDR = BOOT_DOUBLE_TAP_DATA;
51+
R_SYSTEM->PRCR = (uint16_t)BSP_PRV_PRCR_LOCK;
52+
NVIC_SystemReset();
53+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### dfu-util
2+
3+
This board can programmed via DFU bootloader, using e.g. [dfu-util](http://dfu-util.sourceforge.net/).
4+
To enter the DFU bootloader, double tap the reset (blue) button, or you can use `machine.bootloader()` from the MicroPython REPL.
5+
6+
```bash
7+
dfu-util -a 0 -d 2341:0368 -D build-ARDUINO_PORTENTA_C33/firmware.bin -Q # -s :leave
8+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
include("$(PORT_DIR)/boards/manifest.py")
2+
3+
# Networking
4+
require("bundle-networking")
5+
6+
# Utils
7+
require("time")
8+
require("senml")
9+
require("logging")
10+
11+
# Bluetooth
12+
require("aioble")
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef MICROPY_INCLUDED_MBEDTLS_CONFIG_BOARD_H
2+
#define MICROPY_INCLUDED_MBEDTLS_CONFIG_BOARD_H
3+
4+
#define MBEDTLS_ECP_NIST_OPTIM
5+
6+
#include "ports/renesas-ra/mbedtls/mbedtls_config.h"
7+
8+
#endif /* MICROPY_INCLUDED_MBEDTLS_CONFIG_BOARD_H */
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
* The MIT License (MIT)
4+
* Copyright (c) 2023 Arduino SA
5+
*/
6+
7+
// MCU config
8+
#define MICROPY_HW_BOARD_NAME "PORTENTA C33"
9+
#define MICROPY_HW_MCU_NAME "RA6M5"
10+
#define MICROPY_HW_MCU_SYSCLK 200000000
11+
#define MICROPY_HW_MCU_PCLK 100000000
12+
13+
// module config
14+
#define MICROPY_EMIT_THUMB (1)
15+
#define MICROPY_EMIT_INLINE_THUMB (1)
16+
#define MICROPY_PY_BUILTINS_COMPLEX (1)
17+
#define MICROPY_PY_GENERATOR_PEND_THROW (1)
18+
#define MICROPY_PY_MATH (1)
19+
#define MICROPY_PY_UHEAPQ (1)
20+
#define MICROPY_PY_UTIMEQ (1)
21+
#define MICROPY_PY_THREAD (0) // disable ARM_THUMB_FP using vldr due to RA has single float only
22+
#define MICROPY_PY_NETWORK (1)
23+
24+
// peripheral config
25+
#define MICROPY_HW_ENABLE_RNG (1)
26+
#define MICROPY_HW_ENABLE_RTC (1)
27+
#define MICROPY_HW_RTC_SOURCE (1)
28+
#define MICROPY_HW_ENABLE_ADC (1)
29+
#define MICROPY_HW_HAS_FLASH (1)
30+
#define MICROPY_HW_ENABLE_USBDEV (1)
31+
#define MICROPY_HW_ENABLE_UART_REPL (0)
32+
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1)
33+
34+
#define MICROPY_BOARD_STARTUP PORTENTA_C33_board_startup
35+
void PORTENTA_C33_board_startup(void);
36+
37+
#define MICROPY_BOARD_ENTER_BOOTLOADER(nargs, args) PORTENTA_C33_board_enter_bootloader()
38+
void PORTENTA_C33_board_enter_bootloader(void);
39+
40+
// board config
41+
// USB
42+
#define MICROPY_HW_USB_VID (0x2341)
43+
#define MICROPY_HW_USB_PID (0x0468)
44+
45+
// UART
46+
#define MICROPY_HW_UART9_TX (pin_P602)
47+
#define MICROPY_HW_UART9_RX (pin_P110)
48+
#define MICROPY_HW_UART9_CTS (pin_P604)
49+
#define MICROPY_HW_UART9_RTS (pin_P603)
50+
51+
#define MICROPY_HW_UART8_TX (pin_PA00)
52+
#define MICROPY_HW_UART8_RX (pin_P607)
53+
#define MICROPY_HW_UART8_CTS (pin_P801)
54+
#define MICROPY_HW_UART8_RTS (pin_P606)
55+
56+
#if MICROPY_HW_ENABLE_UART_REPL
57+
#define MICROPY_HW_UART_REPL (HW_UART_9)
58+
#define MICROPY_HW_UART_REPL_BAUD (115200)
59+
#endif
60+
61+
// I2C
62+
#define MICROPY_HW_I2C2_SCL (pin_P407)
63+
#define MICROPY_HW_I2C2_SDA (pin_P408)
64+
65+
// SPI
66+
#define MICROPY_HW_SPI1_SSL (pin_P104)
67+
#define MICROPY_HW_SPI1_RSPCK (pin_P102)
68+
#define MICROPY_HW_SPI1_MISO (pin_P100)
69+
#define MICROPY_HW_SPI1_MOSI (pin_P101)
70+
71+
// DAC
72+
#define MICROPY_HW_DAC0 (pin_P014)
73+
#define MICROPY_HW_DAC1 (pin_P015)
74+
75+
// PWM
76+
#define MICROPY_HW_PWM_1A (pin_P105)
77+
#define MICROPY_HW_PWM_8B (pin_P106)
78+
#define MICROPY_HW_PWM_3A (pin_P111)
79+
#define MICROPY_HW_PWM_7B (pin_P303)
80+
#define MICROPY_HW_PWM_6B (pin_P401)
81+
// #define MICROPY_HW_PWM (pin_P210) // AGT
82+
#define MICROPY_HW_PWM_6A (pin_P601)
83+
84+
// LEDs
85+
#define MICROPY_HW_LED1 (pin_P107)
86+
#define MICROPY_HW_LED2 (pin_P400)
87+
#define MICROPY_HW_LED3 (pin_P800)
88+
#define MICROPY_HW_LED_ON(pin) mp_hal_pin_low(pin)
89+
#define MICROPY_HW_LED_OFF(pin) mp_hal_pin_high(pin)
90+
#define MICROPY_HW_LED_TOGGLE(pin) mp_hal_pin_toggle(pin)
91+
92+
// Bluetooth config.
93+
#define MICROPY_HW_BLE_UART_ID (8)
94+
#define MICROPY_HW_BLE_UART_RTS (MICROPY_HW_UART8_RTS)
95+
#define MICROPY_HW_BLE_UART_BAUDRATE (115200)
96+
#define MICROPY_HW_BLE_UART_BAUDRATE_SECONDARY (921600)
97+
98+
// WiFi config.
99+
#define MICROPY_HW_WIFI_SPI_ID (1)
100+
#define MICROPY_HW_WIFI_SPI_CS (pin_P104)
101+
#define MICROPY_HW_WIFI_SPI_BAUDRATE (30 * 1000 * 1000)
102+
#define MICROPY_HW_WIFI_DATAREADY (pin_P803)
103+
#define MICROPY_HW_WIFI_HANDSHAKE (pin_P806)
104+
105+
// ESP hosted control pins
106+
#define MICROPY_HW_ESP_HOSTED_RESET (pin_P804)
107+
#define MICROPY_HW_ESP_HOSTED_GPIO0 (pin_P803)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
CMSIS_MCU = RA6M5
2+
MCU_SERIES = m33
3+
LD_FILES = boards/ARDUINO_PORTENTA_C33/ra6m5.ld
4+
CFLAGS += -DCFG_TUH_MAX_SPEED=OPT_MODE_FULL_SPEED \
5+
-DCFG_TUD_MAX_SPEED=OPT_MODE_HIGH_SPEED \
6+
-DCFG_TUSB_RHPORT0_MODE=0\
7+
-DCFG_TUSB_RHPORT1_MODE=OPT_MODE_DEVICE
8+
9+
# MicroPython settings
10+
MICROPY_VFS_FAT = 1
11+
MICROPY_HW_ENABLE_RNG = 1
12+
MICROPY_PY_BLUETOOTH = 1
13+
MICROPY_BLUETOOTH_NIMBLE = 1
14+
MICROPY_BLUETOOTH_BTSTACK = 0
15+
MICROPY_PY_LWIP = 1
16+
MICROPY_PY_SSL = 1
17+
MICROPY_SSL_MBEDTLS = 1
18+
MICROPY_PY_NETWORK = 1
19+
MICROPY_PY_NETWORK_ESP_HOSTED = 1
20+
21+
FROZEN_MANIFEST = $(BOARD_DIR)/manifest.py
22+
MBEDTLS_CONFIG_FILE = '"$(BOARD_DIR)/mbedtls_config_board.h"'

0 commit comments

Comments
 (0)