Skip to content

Commit 6b4d465

Browse files
iabdalkaderdpgeorge
authored andcommitted
alif: Support running the port on the HE core.
The same MicroPython firmware is built for the HE but with slightly different options, for example no USB. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
1 parent 8f82089 commit 6b4d465

11 files changed

Lines changed: 50 additions & 10 deletions

File tree

ports/alif/alif_flash.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "modalif.h"
3131
#include "ospi_flash.h"
3232

33+
#if MICROPY_HW_ENABLE_OSPI
3334
typedef struct _alif_flash_obj_t {
3435
mp_obj_base_t base;
3536
uint32_t flash_base_addr;
@@ -158,3 +159,4 @@ MP_DEFINE_CONST_OBJ_TYPE(
158159
make_new, alif_flash_make_new,
159160
locals_dict, &alif_flash_locals_dict
160161
);
162+
#endif // MICROPY_HW_ENABLE_OSPI

ports/alif/boards/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
freeze("$(PORT_DIR)/modules")
1+
freeze("$(PORT_DIR)/modules/$(MCU_CORE)")
22
include("$(MPY_DIR)/extmod/asyncio")
33
require("dht")
44
require("neopixel")

ports/alif/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ void _start(void) {
6868
#if MICROPY_HW_ENABLE_UART_REPL
6969
mp_uart_init();
7070
#endif
71-
71+
#if MICROPY_HW_ENABLE_OSPI
7272
if (ospi_flash_init() != 0) {
7373
MICROPY_BOARD_FATAL_ERROR("ospi_init failed");
7474
}
75-
75+
#endif
7676
#if MICROPY_HW_ENABLE_USBDEV
7777
NVIC_ClearPendingIRQ(USB_IRQ_IRQn);
7878
NVIC_SetPriority(USB_IRQ_IRQn, IRQ_PRI_USB);

ports/alif/modalif.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ static MP_DEFINE_CONST_FUN_OBJ_0(alif_info_obj, alif_info);
3737

3838
static const mp_rom_map_elem_t alif_module_globals_table[] = {
3939
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alif) },
40+
#if MICROPY_HW_ENABLE_OSPI
4041
{ MP_ROM_QSTR(MP_QSTR_Flash), MP_ROM_PTR(&alif_flash_type) },
42+
#endif
4143
{ MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&alif_info_obj) },
4244
#if MICROPY_HW_USB_MSC
4345
// Attribute to indicate USB MSC is enabled.

ports/alif/modules/he/_boot.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import openamp
2+
import time
3+
from machine import Pin
4+
5+
6+
def ept_recv_callback(src_addr, data):
7+
print("Received message on endpoint", data)
8+
9+
10+
# Create a new RPMsg endpoint to communicate with main core.
11+
ept = openamp.Endpoint("vuart-channel", callback=ept_recv_callback)
12+
13+
pin = Pin("LED_BLUE", Pin.OUT)
14+
15+
count = 0
16+
while True:
17+
if ept.is_ready():
18+
ept.send("Hello from HE %d" % count, timeout=1000)
19+
count += 1
20+
time.sleep_ms(100)
21+
pin(not pin())

ports/alif/mpconfigport.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@
3636
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES)
3737
#endif
3838

39-
#define MICROPY_HW_ENABLE_UART_REPL (1) // useful if there is no USB
40-
#define MICROPY_HW_ENABLE_USBDEV (1)
41-
39+
#ifndef MICROPY_HW_ENABLE_OSPI
40+
#define MICROPY_HW_ENABLE_OSPI (CORE_M55_HP)
41+
#endif
42+
#ifndef MICROPY_HW_ENABLE_USBDEV
43+
#define MICROPY_HW_ENABLE_USBDEV (CORE_M55_HP)
44+
#endif
4245
#ifndef MICROPY_HW_USB_PRODUCT_FS_STRING
4346
#define MICROPY_HW_USB_PRODUCT_FS_STRING "Board in HS mode"
4447
#endif
45-
#define MICROPY_HW_USB_CDC (1)
48+
#ifndef MICROPY_HW_USB_CDC
49+
#define MICROPY_HW_USB_CDC (CORE_M55_HP)
50+
#endif
4651
#define MICROPY_HW_USB_CDC_TX_TIMEOUT (500)
4752
#ifndef MICROPY_HW_USB_MSC
4853
#define MICROPY_HW_USB_MSC (0)
@@ -53,7 +58,9 @@
5358
#ifndef MICROPY_HW_USB_PID
5459
#define MICROPY_HW_USB_PID (0x9802) // interface has CDC only
5560
#endif
56-
61+
#ifndef MICROPY_HW_ENABLE_UART_REPL
62+
#define MICROPY_HW_ENABLE_UART_REPL (CORE_M55_HP) // useful if there is no USB
63+
#endif
5764
#define MICROPY_HW_FLASH_BLOCK_SIZE_BYTES (4096)
5865

5966
// Memory allocation policies
@@ -78,6 +85,9 @@
7885
#define MICROPY_ENABLE_GC (1)
7986
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
8087
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
88+
#ifndef MICROPY_FLOAT_IMPL
89+
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
90+
#endif
8191
#define MICROPY_SCHEDULER_DEPTH (8)
8292
#define MICROPY_SCHEDULER_STATIC_NODES (1)
8393
#define MICROPY_USE_INTERNAL_ERRNO (1)

ports/alif/mpconfigport.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ MICROPY_VFS_LFS2 ?= 1
1010

1111
# File containing description of content to be frozen into firmware.
1212
FROZEN_MANIFEST ?= boards/manifest.py
13+
MICROPY_MANIFEST_MCU_CORE := $(shell echo $(MCU_CORE) | awk -F'_' '{print tolower($$2)}')

ports/alif/mphalport.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ int mp_hal_stdin_rx_chr(void) {
8585

8686
// Send string of given length
8787
mp_uint_t mp_hal_stdout_tx_strn(const char *str, size_t len) {
88+
#if MICROPY_HW_ENABLE_UART_REPL || MICROPY_HW_USB_CDC || MICROPY_PY_OS_DUPTERM
8889
mp_uint_t ret = len;
8990
bool did_write = false;
91+
#endif
9092

9193
#if MICROPY_HW_ENABLE_UART_REPL
9294
mp_uart_write_strn(str, len);

ports/alif/ospi_flash.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626

2727
#include "py/mperrno.h"
2828
#include "py/mphal.h"
29-
#include "ospi_flash.h"
3029

30+
#if MICROPY_HW_ENABLE_OSPI
31+
#include "ospi_flash.h"
3132
#include "ospi_drv.h"
3233
#include "pinconf.h"
3334

@@ -263,3 +264,4 @@ int ospi_flash_write(uint32_t addr, uint32_t len, const uint8_t *src) {
263264
}
264265
return ret;
265266
}
267+
#endif // MICROPY_HW_ENABLE_OSPI

0 commit comments

Comments
 (0)