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>
This commit is contained in:
iabdalkader
2024-07-17 17:43:38 +03:00
committed by Damien George
parent 8f82089bd0
commit 6b4d46569b
11 changed files with 50 additions and 10 deletions

View File

@@ -30,6 +30,7 @@
#include "modalif.h"
#include "ospi_flash.h"
#if MICROPY_HW_ENABLE_OSPI
typedef struct _alif_flash_obj_t {
mp_obj_base_t base;
uint32_t flash_base_addr;
@@ -158,3 +159,4 @@ MP_DEFINE_CONST_OBJ_TYPE(
make_new, alif_flash_make_new,
locals_dict, &alif_flash_locals_dict
);
#endif // MICROPY_HW_ENABLE_OSPI

View File

@@ -1,4 +1,4 @@
freeze("$(PORT_DIR)/modules")
freeze("$(PORT_DIR)/modules/$(MCU_CORE)")
include("$(MPY_DIR)/extmod/asyncio")
require("dht")
require("neopixel")

View File

@@ -68,11 +68,11 @@ void _start(void) {
#if MICROPY_HW_ENABLE_UART_REPL
mp_uart_init();
#endif
#if MICROPY_HW_ENABLE_OSPI
if (ospi_flash_init() != 0) {
MICROPY_BOARD_FATAL_ERROR("ospi_init failed");
}
#endif
#if MICROPY_HW_ENABLE_USBDEV
NVIC_ClearPendingIRQ(USB_IRQ_IRQn);
NVIC_SetPriority(USB_IRQ_IRQn, IRQ_PRI_USB);

View File

@@ -37,7 +37,9 @@ static MP_DEFINE_CONST_FUN_OBJ_0(alif_info_obj, alif_info);
static const mp_rom_map_elem_t alif_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_alif) },
#if MICROPY_HW_ENABLE_OSPI
{ MP_ROM_QSTR(MP_QSTR_Flash), MP_ROM_PTR(&alif_flash_type) },
#endif
{ MP_ROM_QSTR(MP_QSTR_info), MP_ROM_PTR(&alif_info_obj) },
#if MICROPY_HW_USB_MSC
// Attribute to indicate USB MSC is enabled.

View File

@@ -0,0 +1,21 @@
import openamp
import time
from machine import Pin
def ept_recv_callback(src_addr, data):
print("Received message on endpoint", data)
# Create a new RPMsg endpoint to communicate with main core.
ept = openamp.Endpoint("vuart-channel", callback=ept_recv_callback)
pin = Pin("LED_BLUE", Pin.OUT)
count = 0
while True:
if ept.is_ready():
ept.send("Hello from HE %d" % count, timeout=1000)
count += 1
time.sleep_ms(100)
pin(not pin())

View File

@@ -36,13 +36,18 @@
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES)
#endif
#define MICROPY_HW_ENABLE_UART_REPL (1) // useful if there is no USB
#define MICROPY_HW_ENABLE_USBDEV (1)
#ifndef MICROPY_HW_ENABLE_OSPI
#define MICROPY_HW_ENABLE_OSPI (CORE_M55_HP)
#endif
#ifndef MICROPY_HW_ENABLE_USBDEV
#define MICROPY_HW_ENABLE_USBDEV (CORE_M55_HP)
#endif
#ifndef MICROPY_HW_USB_PRODUCT_FS_STRING
#define MICROPY_HW_USB_PRODUCT_FS_STRING "Board in HS mode"
#endif
#define MICROPY_HW_USB_CDC (1)
#ifndef MICROPY_HW_USB_CDC
#define MICROPY_HW_USB_CDC (CORE_M55_HP)
#endif
#define MICROPY_HW_USB_CDC_TX_TIMEOUT (500)
#ifndef MICROPY_HW_USB_MSC
#define MICROPY_HW_USB_MSC (0)
@@ -53,7 +58,9 @@
#ifndef MICROPY_HW_USB_PID
#define MICROPY_HW_USB_PID (0x9802) // interface has CDC only
#endif
#ifndef MICROPY_HW_ENABLE_UART_REPL
#define MICROPY_HW_ENABLE_UART_REPL (CORE_M55_HP) // useful if there is no USB
#endif
#define MICROPY_HW_FLASH_BLOCK_SIZE_BYTES (4096)
// Memory allocation policies
@@ -78,6 +85,9 @@
#define MICROPY_ENABLE_GC (1)
#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#ifndef MICROPY_FLOAT_IMPL
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
#endif
#define MICROPY_SCHEDULER_DEPTH (8)
#define MICROPY_SCHEDULER_STATIC_NODES (1)
#define MICROPY_USE_INTERNAL_ERRNO (1)

View File

@@ -10,3 +10,4 @@ MICROPY_VFS_LFS2 ?= 1
# File containing description of content to be frozen into firmware.
FROZEN_MANIFEST ?= boards/manifest.py
MICROPY_MANIFEST_MCU_CORE := $(shell echo $(MCU_CORE) | awk -F'_' '{print tolower($$2)}')

View File

@@ -85,8 +85,10 @@ int mp_hal_stdin_rx_chr(void) {
// Send string of given length
mp_uint_t mp_hal_stdout_tx_strn(const char *str, size_t len) {
#if MICROPY_HW_ENABLE_UART_REPL || MICROPY_HW_USB_CDC || MICROPY_PY_OS_DUPTERM
mp_uint_t ret = len;
bool did_write = false;
#endif
#if MICROPY_HW_ENABLE_UART_REPL
mp_uart_write_strn(str, len);

View File

@@ -26,8 +26,9 @@
#include "py/mperrno.h"
#include "py/mphal.h"
#include "ospi_flash.h"
#if MICROPY_HW_ENABLE_OSPI
#include "ospi_flash.h"
#include "ospi_drv.h"
#include "pinconf.h"
@@ -263,3 +264,4 @@ int ospi_flash_write(uint32_t addr, uint32_t len, const uint8_t *src) {
}
return ret;
}
#endif // MICROPY_HW_ENABLE_OSPI

View File

@@ -44,7 +44,7 @@
#define CFG_TUSB_DEBUG 0
// Enable Device stack
#define CFG_TUD_ENABLED 1
#define CFG_TUD_ENABLED (CORE_M55_HP)
// Default is max speed that hardware controller could support with on-chip PHY
#define CFG_TUD_MAX_SPEED OPT_MODE_HIGH_SPEED