Skip to content

Commit 3de1b9e

Browse files
committed
Merge remote-tracking branch 'upstream/master' into stm32-displayio
2 parents e6b4565 + 15886b1 commit 3de1b9e

File tree

48 files changed

+349
-195
lines changed

Some content is hidden

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

48 files changed

+349
-195
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ jobs:
169169
run: |
170170
sudo apt-get install -y gettext
171171
pip install requests sh click setuptools awscli
172-
wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~xenial1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb
172+
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
173+
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
173174
- name: Versions
174175
run: |
175176
gcc --version

drivers/wiznet5k/internet/dns/dns.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
#include <string.h>
5454
#include <stdlib.h>
55-
#include "tick.h"
55+
#include "supervisor/shared/tick.h"
5656

5757
//#include "Ethernet/socket.h"
5858
//#include "Internet/DNS/dns.h"
@@ -125,7 +125,7 @@ uint16_t DNS_MSGID; // DNS message ID
125125

126126

127127
uint32_t HAL_GetTick(void) {
128-
return ticks_ms;
128+
return supervisor_ticks_ms32();
129129
}
130130

131131
uint32_t hal_sys_tick;

locale/zh_Latn_pinyin.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,11 +673,11 @@ msgstr "Shūrù/shūchū cuòwù"
673673

674674
#: ports/nrf/common-hal/_bleio/__init__.c
675675
msgid "Insufficient authentication"
676-
msgstr ""
676+
msgstr "Rènzhèng bùzú"
677677

678678
#: ports/nrf/common-hal/_bleio/__init__.c
679679
msgid "Insufficient encryption"
680-
msgstr ""
680+
msgstr "Jiāmì bùzú"
681681

682682
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
683683
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
@@ -2465,7 +2465,7 @@ msgstr "time.struct_time() xūyào 9 xùliè"
24652465

24662466
#: shared-bindings/busio/UART.c
24672467
msgid "timeout must be 0.0-100.0 seconds"
2468-
msgstr ""
2468+
msgstr "Chāo shí shíjiān bìxū wèi 0.0 Dào 100.0 Miǎo"
24692469

24702470
#: shared-bindings/_bleio/CharacteristicBuffer.c
24712471
msgid "timeout must be >= 0.0"

ports/atmel-samd/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,16 @@ else
122122
ifdef CFLAGS_INLINE_LIMIT
123123
CFLAGS += -finline-limit=$(CFLAGS_INLINE_LIMIT)
124124
endif
125+
125126
CFLAGS += -flto -flto-partition=none
127+
128+
ifeq ($(CIRCUITPY_SMALL_BUILD),1)
129+
CFLAGS += --param inline-unit-growth=15 --param max-inline-insns-auto=20
130+
endif
131+
132+
ifdef CFLAGS_BOARD
133+
CFLAGS += $(CFLAGS_BOARD)
134+
endif
126135
endif
127136

128137
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT)

ports/atmel-samd/background.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "audio_dma.h"
2929
#include "tick.h"
3030
#include "supervisor/filesystem.h"
31+
#include "supervisor/shared/tick.h"
3132
#include "supervisor/usb.h"
3233

3334
#include "py/runtime.h"
@@ -44,6 +45,23 @@ bool stack_ok_so_far = true;
4445

4546
static bool running_background_tasks = false;
4647

48+
#ifdef MONITOR_BACKGROUND_TASKS
49+
// PB03 is physical pin "SCL" on the Metro M4 express
50+
// so you can't use this code AND an i2c peripheral
51+
// at the same time unless you change this
52+
STATIC void start_background_task(void) {
53+
REG_PORT_DIRSET1 = (1<<3);
54+
REG_PORT_OUTSET1 = (1<<3);
55+
}
56+
57+
STATIC void finish_background_task(void) {
58+
REG_PORT_OUTCLR1 = (1<<3);
59+
}
60+
#else
61+
STATIC void start_background_task(void) {}
62+
STATIC void finish_background_task(void) {}
63+
#endif
64+
4765
void background_tasks_reset(void) {
4866
running_background_tasks = false;
4967
}
@@ -53,6 +71,9 @@ void run_background_tasks(void) {
5371
if (running_background_tasks) {
5472
return;
5573
}
74+
75+
start_background_task();
76+
5677
assert_heap_ok();
5778
running_background_tasks = true;
5879

@@ -71,9 +92,10 @@ void run_background_tasks(void) {
7192
running_background_tasks = false;
7293
assert_heap_ok();
7394

74-
last_finished_tick = ticks_ms;
95+
last_finished_tick = supervisor_ticks_ms64();
96+
finish_background_task();
7597
}
7698

7799
bool background_tasks_ok(void) {
78-
return ticks_ms - last_finished_tick < 1000;
100+
return supervisor_ticks_ms64() - last_finished_tick < 1000;
79101
}

ports/atmel-samd/boards/pewpew10/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ CIRCUITPY_USB_MIDI = 0
2323
SUPEROPT_GC = 0
2424

2525
FROZEN_MPY_DIRS += $(TOP)/frozen/pew-pewpew-standalone-10.x
26+
27+
CFLAGS_BOARD = --param max-inline-insns-auto=15

ports/atmel-samd/boards/pirkey_m0/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ SUPEROPT_GC = 0
2929
# FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar
3030
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID
3131
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_IRRemote
32+
33+
CFLAGS_BOARD = --param max-inline-insns-auto=12

ports/atmel-samd/boards/pyruler/mpconfigboard.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ CIRCUITPY_SMALL_BUILD = 1
1313

1414
SUPEROPT_GC = 0
1515

16+
CFLAGS_BOARD = --param max-inline-insns-auto=15
1617
ifeq ($(TRANSLATION), zh_Latn_pinyin)
1718
CFLAGS_INLINE_LIMIT = 35
18-
endif
19+
endif

ports/atmel-samd/boards/trinket_m0/mpconfigboard.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ LONGINT_IMPL = NONE
1212
CIRCUITPY_SMALL_BUILD = 1
1313

1414
SUPEROPT_GC = 0
15+
16+
CFLAGS_BOARD = --param max-inline-insns-auto=15
17+
ifeq ($(TRANSLATION), zh_Latn_pinyin)
18+
CFLAGS_INLINE_LIMIT = 35
19+
endif
20+

ports/atmel-samd/common-hal/busio/UART.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
#include "py/runtime.h"
3535
#include "py/stream.h"
3636
#include "supervisor/shared/translate.h"
37-
38-
#include "tick.h"
37+
#include "supervisor/shared/tick.h"
3938

4039
#include "hpl_sercom_config.h"
4140
#include "peripheral_clk_config.h"
@@ -272,10 +271,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
272271
usart_async_get_io_descriptor(usart_desc_p, &io);
273272

274273
size_t total_read = 0;
275-
uint64_t start_ticks = ticks_ms;
274+
uint64_t start_ticks = supervisor_ticks_ms64();
276275

277276
// Busy-wait until timeout or until we've read enough chars.
278-
while (ticks_ms - start_ticks <= self->timeout_ms) {
277+
while (supervisor_ticks_ms64() - start_ticks <= self->timeout_ms) {
279278
// Read as many chars as we can right now, up to len.
280279
size_t num_read = io_read(io, data, len);
281280

@@ -289,7 +288,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t
289288
}
290289
if (num_read > 0) {
291290
// Reset the timeout on every character read.
292-
start_ticks = ticks_ms;
291+
start_ticks = supervisor_ticks_ms64();
293292
}
294293
RUN_BACKGROUND_TASKS;
295294
// Allow user to break out of a timeout with a KeyboardInterrupt.

ports/atmel-samd/common-hal/time/__init__.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828

2929
#include "shared-bindings/time/__init__.h"
3030

31-
#include "tick.h"
31+
#include "supervisor/shared/tick.h"
3232

3333
inline uint64_t common_hal_time_monotonic() {
34-
return ticks_ms;
34+
return supervisor_ticks_ms64();
3535
}
3636

3737
void common_hal_time_delay_ms(uint32_t delay) {

ports/atmel-samd/mphalport.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
#include "mpconfigboard.h"
4646
#include "mphalport.h"
4747
#include "reset.h"
48-
#include "tick.h"
48+
#include "supervisor/shared/tick.h"
4949

5050
extern uint32_t common_hal_mcu_processor_get_frequency(void);
5151

5252
void mp_hal_delay_ms(mp_uint_t delay) {
53-
uint64_t start_tick = ticks_ms;
53+
uint64_t start_tick = supervisor_ticks_ms64();
5454
uint64_t duration = 0;
5555
while (duration < delay) {
5656
RUN_BACKGROUND_TASKS;
@@ -59,7 +59,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
5959
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
6060
break;
6161
}
62-
duration = (ticks_ms - start_tick);
62+
duration = (supervisor_ticks_ms64() - start_tick);
6363
// TODO(tannewt): Go to sleep for a little while while we wait.
6464
}
6565
}

ports/atmel-samd/mphalport.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131

3232
#include "lib/oofatfs/ff.h"
3333

34-
// Global millisecond tick count (driven by SysTick interrupt).
35-
extern volatile uint64_t ticks_ms;
34+
#include "supervisor/shared/tick.h"
3635

36+
// Global millisecond tick count (driven by SysTick interrupt).
3737
static inline mp_uint_t mp_hal_ticks_ms(void) {
38-
return ticks_ms;
38+
return supervisor_ticks_ms32();
3939
}
4040
// Number of bytes in receive buffer
4141
volatile uint8_t usb_rx_count;

ports/atmel-samd/tick.c

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,47 +28,21 @@
2828

2929
#include "peripheral_clk_config.h"
3030

31-
#include "supervisor/shared/autoreload.h"
32-
#include "supervisor/filesystem.h"
31+
#include "supervisor/shared/tick.h"
3332
#include "shared-bindings/microcontroller/__init__.h"
3433
#include "shared-bindings/microcontroller/Processor.h"
3534

36-
#if CIRCUITPY_GAMEPAD
37-
#include "shared-module/gamepad/__init__.h"
38-
#endif
39-
40-
#if CIRCUITPY_GAMEPADSHIFT
41-
#include "shared-module/gamepadshift/__init__.h"
42-
#endif
43-
// Global millisecond tick count
44-
volatile uint64_t ticks_ms = 0;
45-
4635
void SysTick_Handler(void) {
4736
// SysTick interrupt handler called when the SysTick timer reaches zero
4837
// (every millisecond).
4938
common_hal_mcu_disable_interrupts();
50-
ticks_ms += 1;
5139

5240
// Read the control register to reset the COUNTFLAG.
5341
(void) SysTick->CTRL;
5442
common_hal_mcu_enable_interrupts();
5543

56-
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
57-
filesystem_tick();
58-
#endif
59-
#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
60-
autoreload_tick();
61-
#endif
62-
#ifdef CIRCUITPY_GAMEPAD_TICKS
63-
if (!(ticks_ms & CIRCUITPY_GAMEPAD_TICKS)) {
64-
#if CIRCUITPY_GAMEPAD
65-
gamepad_tick();
66-
#endif
67-
#if CIRCUITPY_GAMEPADSHIFT
68-
gamepadshift_tick();
69-
#endif
70-
}
71-
#endif
44+
// Do things common to all ports when the tick occurs
45+
supervisor_tick();
7246
}
7347

7448
void tick_init() {
@@ -115,7 +89,7 @@ void current_tick(uint64_t* ms, uint32_t* us_until_ms) {
11589
uint32_t tick_status = SysTick->CTRL;
11690
uint32_t current_us = SysTick->VAL;
11791
uint32_t tick_status2 = SysTick->CTRL;
118-
uint64_t current_ms = ticks_ms;
92+
uint64_t current_ms = supervisor_ticks_ms64();
11993
// The second clause ensures our value actually rolled over. Its possible it hit zero between
12094
// the VAL read and CTRL read.
12195
if ((tick_status & SysTick_CTRL_COUNTFLAG_Msk) != 0 ||
@@ -129,5 +103,5 @@ void current_tick(uint64_t* ms, uint32_t* us_until_ms) {
129103

130104
void wait_until(uint64_t ms, uint32_t us_until_ms) {
131105
uint32_t ticks_per_us = common_hal_mcu_processor_get_frequency() / 1000 / 1000;
132-
while (ticks_ms <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {}
106+
while (supervisor_ticks_ms64() <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {}
133107
}

ports/atmel-samd/tick.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
#include "py/mpconfig.h"
3030

31-
extern volatile uint64_t ticks_ms;
32-
3331
extern struct timer_descriptor ms_timer;
3432

3533
void tick_init(void);

ports/cxd56/common-hal/time/__init__.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
#include "py/mphal.h"
2828

29-
#include "tick.h"
29+
#include "supervisor/shared/tick.h"
3030

3131
uint64_t common_hal_time_monotonic(void) {
32-
return ticks_ms;
32+
return supervisor_ticks_ms64();
3333
}
3434

3535
void common_hal_time_delay_ms(uint32_t delay) {

ports/cxd56/mphalport.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#include "py/mpstate.h"
3333

34-
#include "tick.h"
34+
#include "supervisor/shared/tick.h"
3535

3636
#define DELAY_CORRECTION (700)
3737
#define DELAY_INTERVAL (50)
@@ -57,7 +57,7 @@ mp_uint_t mp_hal_ticks_cpu(void) {
5757
}
5858

5959
void mp_hal_delay_ms(mp_uint_t delay) {
60-
uint64_t start_tick = ticks_ms;
60+
uint64_t start_tick = supervisor_ticks_ms64();
6161
uint64_t duration = 0;
6262
while (duration < delay) {
6363
#ifdef MICROPY_VM_HOOK_LOOP
@@ -68,7 +68,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
6868
MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
6969
break;
7070
}
71-
duration = (ticks_ms - start_tick);
71+
duration = (supervisor_ticks_ms64() - start_tick);
7272
// TODO(tannewt): Go to sleep for a little while while we wait.
7373
}
7474
}

ports/cxd56/mphalport.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,4 @@
3131

3232
#include "lib/utils/interrupt_char.h"
3333

34-
extern volatile uint64_t ticks_ms;
35-
3634
#endif // MICROPY_INCLUDED_CXD56_MPHALPORT_H

ports/cxd56/tick.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,10 @@
2727
#include "tick.h"
2828

2929
#include "supervisor/shared/autoreload.h"
30-
#include "supervisor/filesystem.h"
31-
32-
// Global millisecond tick count
33-
volatile uint64_t ticks_ms = 0;
30+
#include "supervisor/shared/tick.h"
3431

3532
void board_timerhook(void)
3633
{
37-
ticks_ms += 1;
38-
39-
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
40-
filesystem_tick();
41-
#endif
42-
#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
43-
autoreload_tick();
44-
#endif
34+
// Do things common to all ports when the tick occurs
35+
supervisor_tick();
4536
}

ports/cxd56/tick.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,4 @@
2929

3030
#include "py/mpconfig.h"
3131

32-
extern volatile uint64_t ticks_ms;
33-
3432
#endif // MICROPY_INCLUDED_CXD56_TICK_H

0 commit comments

Comments
 (0)