Skip to content

Commit 9485634

Browse files
committed
Add support for REPL on Arduino Zero through EDBG via UART.
1 parent 8f26d18 commit 9485634

Some content is hidden

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

54 files changed

+21507
-110
lines changed

atmel-samd/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tools/bossac* binary

atmel-samd/Makefile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Select the board to build for: if not given on the command line,
22
# then default to PYBV10.
3-
BOARD ?= feather_m0_ble
3+
BOARD ?= arduino_zero
44
ifeq ($(wildcard boards/$(BOARD)/.),)
55
$(error Invalid BOARD specified)
66
endif
@@ -54,6 +54,7 @@ INC += $(addprefix -Iasf/sam0/,\
5454
drivers/system/pinmux \
5555
drivers/system/power/power_sam_d_r \
5656
drivers/system/reset/reset_sam_d_r \
57+
drivers/sercom/ \
5758
drivers/usb/ \
5859
utils \
5960
utils/cmsis/samd21/include \
@@ -92,8 +93,13 @@ endif
9293

9394
SRC_ASF = $(addprefix asf/sam0/,\
9495
drivers/port/port.c \
96+
drivers/sercom/sercom.c \
97+
drivers/sercom/sercom_interrupt.c \
98+
drivers/sercom/usart/usart.c \
99+
drivers/sercom/usart/usart_interrupt.c \
95100
drivers/system/clock/clock_samd21_r21_da/clock.c \
96101
drivers/system/clock/clock_samd21_r21_da/gclk.c \
102+
drivers/system/interrupt/system_interrupt.c \
97103
drivers/system/pinmux/pinmux.c \
98104
drivers/system/system.c \
99105
drivers/usb/stack_interface/usb_device_udd.c \
@@ -104,12 +110,16 @@ SRC_ASF = $(addprefix asf/sam0/,\
104110
SRC_C = \
105111
main.c \
106112
mphalport.c \
113+
uart.c \
107114
asf/common/services/sleepmgr/samd/sleepmgr.c \
108115
asf/common/services/usb/class/cdc/device/udi_cdc.c \
109116
asf/common/services/usb/class/cdc/device/udi_cdc_desc.c \
110117
asf/common/services/usb/udc/udc.c \
111118
asf/common/utils/interrupt/interrupt_sam_nvic.c \
112119
asf/common2/services/delay/sam0/systick_counter.c \
120+
asf/sam0/utils/cmsis/samd21/source/gcc/startup_samd21.c \
121+
asf/sam0/utils/cmsis/samd21/source/system_samd21.c \
122+
asf/sam0/utils/syscalls/gcc/syscalls.c \
113123
lib/utils/stdout_helpers.c \
114124
lib/utils/printf.c \
115125
lib/utils/pyexec.c \
@@ -137,7 +147,7 @@ $(BUILD)/firmware.elf: $(OBJ)
137147

138148
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
139149
$(ECHO) "Create $@"
140-
$(Q)$(OBJCOPY) -O binary -j .isr_vector -j .text -j .data $^ $@
150+
$(Q)$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
141151

142152
deploy: $(BUILD)/firmware.bin
143153
$(ECHO) "Writing $< to the board"

atmel-samd/README.md

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,47 @@ This port is intended to be a full featured MicroPython port for SAMD21x18 based
44
development boards including the Arduino Zero, Adafruit Feather M0 and Adafruit
55
M0 BLE.
66

7-
## Building for a SAMD21x18 MCU
7+
## Building
88

99
The Makefile has the ability to build for a SAMD21x18, and by default
1010
includes some start-up code and also enables a UART for communication. To build:
1111

12-
$ make CROSS=1
12+
make CROSS=1
1313

14-
If you previously built the Linux version, you will need to first run
15-
`make clean` to get rid of incompatible object files.
14+
It will build for the Arduino Zero by default. You may change it by setting `BOARD`. For example:
1615

17-
Deploying coming soon!
16+
make CROSS=1 BOARD=feather_m0_ble
17+
18+
Board names are the directory names in the `boards` folder.
19+
20+
## Deploying
21+
22+
### Arduino Bootloader
23+
If your board has an existing Arduino bootloader on it then you can use bossac to flash MicroPython. After building run:
24+
25+
tools/bossac_osx -e -w -v -b build-feather_m0_ble/firmware.bin
26+
27+
### No Bootloader via GDB
28+
This method works for loading MicroPython onto the Arduino Zero via the programming port rather than the native USB port.
29+
30+
Note: These instructions are tested on Mac OSX and will vary for different platforms.
31+
32+
openocd -f ~/Library/Arduino15/packages/arduino/hardware/samd/1.6.6/variants/arduino_zero/openocd_scripts/arduino_zero.cfg
33+
34+
In another terminal from `micropython/atmel-samd`:
35+
36+
arm-none-eabi-gdb build-arduino_zero/firmware.elf
37+
(gdb) tar ext :3333
38+
...
39+
(gdb) load
40+
...
41+
(gdb) monitor reset init
42+
...
43+
(gdb) continue
44+
45+
## Connecting
46+
The current Atmel SAMD implementation only works over UART. To connect to it from OSX do something like this:
47+
48+
screen /dev/tty.usbmodem142422 115200
49+
50+
You may not see a prompt immediately because it doesn't know you connected. To get one either hit enter to get `>>>` or do CTRL-B to get the full header.

atmel-samd/asf/sam0/drivers/sercom/i2c/docimg/bus_state_diagram.svg

Lines changed: 533 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)