Skip to content

Commit 2f95cc9

Browse files
committed
litex: move more critical code to RAM
The XIP SPI flash on Fomu is slow, which results in certain operations taking a long time. This becomes a problem for time-critical operations such as USB. Move various calls into RAM to improve performance. This includes the call to __modsi3 and __udivsi3 which are used by the supervisor handler to determine if periodic callbacks need to be run. This finishes fixing adafruit#3841 Signed-off-by: Sean Cross <[email protected]>
1 parent f3e5441 commit 2f95cc9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

ports/litex/boards/fomu/fomu-spi.ld

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ SECTIONS
5151
*(.text.tu_edpt_dir)
5252
*(.text.tu_fifo_empty)
5353
*(.text.usbd_edpt_busy)
54+
*(.text.usb_irq_handler)
55+
*(.text.supervisor_tick)
56+
*(.text.port_get_raw_ticks)
57+
*(.text.__modsi3)
58+
*(.text.__udivsi3)
5459
*(.text.irq_getmask)
5560
*(.text.irq_setmask)
5661
*(.text.irq_pending)

ports/litex/common-hal/microcontroller/__init__.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,15 @@ void common_hal_mcu_delay_us(uint32_t delay) {
5959

6060
volatile uint32_t nesting_count = 0;
6161

62+
__attribute__((section(".ramtext")))
6263
void common_hal_mcu_disable_interrupts(void) {
63-
irq_setie(0);
64-
// __DMB();
64+
if (nesting_count == 0) {
65+
irq_setie(0);
66+
}
6567
nesting_count++;
6668
}
6769

70+
__attribute__((section(".ramtext")))
6871
void common_hal_mcu_enable_interrupts(void) {
6972
if (nesting_count == 0) {
7073
// This is very very bad because it means there was mismatched disable/enables so we

0 commit comments

Comments
 (0)