Skip to content

Commit a5f6cb3

Browse files
committed
Compiled and linked SAMD21x18 version successfully.
1 parent f2a21a2 commit a5f6cb3

File tree

12 files changed

+613
-0
lines changed

12 files changed

+613
-0
lines changed

atmel-samd/Makefile

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
include ../py/mkenv.mk
2+
3+
CROSS = 0
4+
5+
# qstr definitions (must come before including py.mk)
6+
QSTR_DEFS = qstrdefsport.h
7+
8+
# include py core make definitions
9+
include ../py/py.mk
10+
11+
ifeq ($(CROSS), 1)
12+
CROSS_COMPILE = arm-none-eabi-
13+
endif
14+
15+
BOSSAC := /Users/tannewt/ArduinoCore-samd/tools/bossac_osx
16+
17+
INC += -I.
18+
INC += -I..
19+
INC += -I../lib/mp-readline
20+
INC += -I$(BUILD)
21+
22+
ifeq ($(CROSS), 1)
23+
CFLAGS_CORTEX_M0 = -mthumb -mabi=aapcs-linux -mcpu=cortex-m0plus -fsingle-precision-constant -Wdouble-promotion -D__SAMD21G18A__
24+
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M0) $(COPT)
25+
else
26+
CFLAGS = -m32 $(INC) -Wall -Werror -ansi -std=gnu99 $(COPT)
27+
endif
28+
29+
#Debugging/Optimization
30+
ifeq ($(DEBUG), 1)
31+
CFLAGS += -O0 -ggdb
32+
else
33+
CFLAGS += -Os -DNDEBUG
34+
endif
35+
36+
LIBS =
37+
ifeq ($(CROSS), 1)
38+
LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
39+
LDFLAGS = -Lasf/thirdparty/CMSIS/Lib/GCC/ -L $(dir $(LIBGCC_FILE_NAME)) -nostdlib -T samd21.ld -Map=$@.map --cref
40+
LIBS += -larm_cortexM0l_math -lgcc
41+
else
42+
LD = gcc
43+
LDFLAGS = -m32 -Wl,-Map=$@.map,--cref
44+
endif
45+
46+
SRC_C = \
47+
main.c \
48+
uart_core.c \
49+
lib/utils/stdout_helpers.c \
50+
lib/utils/printf.c \
51+
lib/utils/pyexec.c \
52+
lib/libc/string0.c \
53+
lib/mp-readline/readline.c \
54+
$(BUILD)/_frozen_mpy.c \
55+
56+
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
57+
58+
ifeq ($(CROSS), 1)
59+
all: $(BUILD)/firmware.bin
60+
else
61+
all: $(BUILD)/firmware.elf
62+
endif
63+
64+
$(BUILD)/_frozen_mpy.c: frozentest.mpy $(BUILD)/genhdr/qstrdefs.generated.h
65+
$(ECHO) "MISC freezing bytecode"
66+
$(Q)../tools/mpy-tool.py -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h -mlongint-impl=none $< > $@
67+
68+
$(BUILD)/firmware.elf: $(OBJ)
69+
$(ECHO) "LINK $@"
70+
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
71+
$(Q)$(SIZE) $@
72+
73+
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
74+
$(ECHO) "Create $@"
75+
$(Q)$(OBJCOPY) -O binary -j .isr_vector -j .text -j .data $^ $@
76+
77+
deploy: $(BUILD)/firmware.bin
78+
$(ECHO) "Writing $< to the board"
79+
$(BOSSAC) -u $<
80+
81+
# Run emulation build on a POSIX system with suitable terminal settings
82+
run:
83+
stty raw opost -echo
84+
build/firmware.elf
85+
@echo Resetting terminal...
86+
# This sleep is useful to spot segfaults
87+
sleep 1
88+
reset
89+
90+
test: $(BUILD)/firmware.elf
91+
$(Q)/bin/echo -e "print('hello world!', list(x+1 for x in range(10)), end='eol\\\\n')\\r\\n\\x04" | $(BUILD)/firmware.elf | tail -n2 | grep "^hello world! \\[1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\]eol"
92+
93+
include ../py/mkrules.mk

atmel-samd/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# SAMD21x18
2+
3+
This port is intended to be a full featured MicroPython port for SAMD21x18 based
4+
development boards including the Arduino Zero, Adafruit Feather M0 and Adafruit
5+
M0 BLE.
6+
7+
## Building for a SAMD21x18 MCU
8+
9+
The Makefile has the ability to build for a SAMD21x18, and by default
10+
includes some start-up code and also enables a UART for communication. To build:
11+
12+
$ make CROSS=1
13+
14+
If you previously built the Linux version, you will need to first run
15+
`make clean` to get rid of incompatible object files.
16+
17+
Deploying coming soon!
144 KB
Binary file not shown.

atmel-samd/asf/readme.txt

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
1 - Introduction
2+
----------------
3+
4+
The Atmel� Software Framework (ASF) is a collection of embedded software for Atmel flash MCU (www.atmel.com/asf).
5+
� It simplifies the usage of microcontrollers, providing an abstraction to the hardware and high-value middlewares
6+
� ASF is designed to be used for evaluation, prototyping, design and production phases
7+
� ASF is integrated in the Atmel Studio IDE with a graphical user interface or available as standalone for GCC, IAR compilers
8+
� ASF can be downloaded for free
9+
10+
ASF online documentation can be found here: http://asf.atmel.com
11+
12+
Supported devices:
13+
� AVR UC3(Trade Mark) (http://www.atmel.com/products/microcontrollers/avr/32-bitavruc3.aspx)
14+
� AVR XMEGA(Trade Mark) (http://www.atmel.com/products/microcontrollers/avr/avr_xmega.aspx)
15+
� megaAVR(Trade Mark) (http://www.atmel.com/products/microcontrollers/avr/megaavr.aspx)
16+
� SAM (http://www.atmel.com/products/microcontrollers/arm/default.aspx)
17+
18+
Each software module is provided with full source code, example of usage and
19+
ready-to-use projects for the IAR EW and GNU GCC compilers.
20+
21+
This package is dedicated for IAR and GCC makefile users. AVR Studio 5 or Atmel Studio 6 users do not
22+
need this package as the ASF is integrated in Atmel Studio.
23+
24+
The top folder organization is as follow:
25+
- the avr32/ folder contains software modules(source code and projects) dedicated to AVR UC3 devices,
26+
- the mega/ folder contains software modules(source code and projects) dedicated to megaAVR devices,
27+
- the xmega/ folder contains software modules(source code and projects) dedicated to AVR XMEGA devices,
28+
- the sam/ folder contains software modules(source code and projects) dedicated to SAM devices,
29+
- the common/ folder contains software modules(source code and projects) shared by all AVR and SAM devices,
30+
- the thirdparty/ folder contains software modules(source code and projects) from thirdparty providers for all Atmel devices.
31+
32+
The thirdparty/ folder is organized by thirdparty software module (i.e. one folder per thirdparty software module).
33+
34+
The avr32/, xmega/, mega/, sam/ and common/ folders are organized as follow:
35+
- the drivers/ folder contains low-level software drivers for MCU on-chip resources (eg cpu, usart, adc drivers).
36+
- the boards/ folder contains board-specific source code files.
37+
- the utils/ folder contains files that are used by all other modules: it holds
38+
several linker script files, IAR & GCC pre-compiled libraries of some ASF modules,
39+
and C/C++ utility files with general usage defines, macros and functions.
40+
- the services/ folder contains application-oriented pieces of software that are
41+
not specific to boards nor chips (eg. FAT, TCP/IP stack, os, JPEG decoder).
42+
For the common/ top folder, the services/ folder also contains chip-specific code.
43+
- the components/ folder offers, for each supported hardware component, a software
44+
interface to interact with the component (eg memories like SDRAM, SD card, or display)
45+
- the applications/ contains hefty examples of applications using services and drivers.
46+
47+
48+
2 - Documentation
49+
--------------------------
50+
51+
ASF release notes, reference manual and getting started documents can be found on http://www.atmel.com/asf.
52+
53+
The ASF documentation can be found online on http://asf.atmel.com.
54+
55+
56+
3 - Toolchain Header Files Update
57+
---------------------------------
58+
59+
For 8-bit AVR users it is recommended to update the toolchain header files, a
60+
description about how to do that is located in the readme.txt file under the
61+
xmega/utils/header_files/ directory.
62+
63+
For AVR UC3 users using IAR, it is recommended to update the IAR header files.
64+
To do that, unzip the avr32-headers.zip file (located under
65+
the avr32/utils/header_files/ directory) to the IAR EWAVR32 installation folder
66+
under "IAR installation folder"/Embedded Workbench x.y/avr32/inc/.
67+
68+
69+
4 - IAR EW Users
70+
----------------
71+
72+
Using an example of usage of the AVR UC3 GPIO driver module as an example, the
73+
IAR projects are located under:
74+
- avr32/drivers/gpio/peripheral_bus_example/at32uc3a0512_evk1000/iar/ for an EVK1100 board,
75+
- avr32/drivers/gpio/peripheral_bus_example/at32uc3a0512_evk1105/iar/ for an EVK1105 board,
76+
- avr32/drivers/gpio/peripheral_bus_example/at32uc3b0256_evk1101/iar/ for an EVK1101 board,
77+
- avr32/drivers/gpio/peripheral_bus_example/at32uc3a3256_evk1104/iar/ for an EVK1104 board,
78+
- avr32/drivers/gpio/peripheral_bus_example/at32uc3l064_stk600-rcuc3l0/iar/ for an STK600-RCUC3L0 setup,
79+
- avr32/drivers/gpio/peripheral_bus_example/at32uc3c0512c_uc3c_ek/iar/ for an AT32UC3C-EK board,
80+
- avr32/drivers/gpio/peripheral_bus_example/at32uc3l064_uc3l_ek/iar/ for an AT32UC3L-EK board.
81+
82+
Each iar folder contains a full IAR project with:
83+
- an IAR EWAVR32 workspace file(avr32_drivers_gpio_peripheral_bus_example_uc3l_ek.eww: double-click on this file to open the whole project),
84+
- an IAR EWAVR32 project file(avr32_drivers_gpio_peripheral_bus_example_uc3l_ek.ewp),
85+
- an IAR EWAVR32 debug configuration file(avr32_drivers_gpio_peripheral_bus_example_uc3l_ek.ewd).
86+
87+
88+
5 - AVR32 Studio Users
89+
----------------------
90+
91+
It is possible to work with an unzipped ASF package from within AVR32 Studio: this
92+
is described in the application note "AVR32769: How to Compile the standalone AVR
93+
UC3 Software Framework in AVR32 Studio V2": http://www.atmel.com/dyn/resources/prod_documents/doc32115.pdf
94+
95+
96+
6 - Offline documentation - Generating The HTML Documentation
97+
-------------------------------------
98+
99+
All modules are fully documented using doxygen tags. Each project within the ASF
100+
contains a doxyfile.doxygen (used to configure doxygen for a proper documentation
101+
generation): to generate the html documentation, doxygen must be installed (see
102+
http://www.doxygen.org/download.html) and the doxyfile.doxygen must be used as
103+
the input configuration file for doxygen.
104+
105+
Using an example of usage of the AVR UC3 GPIO driver module as an example, for
106+
an AT32UC3C-EK board, the associated doxyfile.doxygen file is under the
107+
avr32/drivers/gpio/peripheral_bus_example/at32uc3c0512c_uc3c_ek/doxygen/ folder.
108+
Run doxygen and use this doxyfile.doxygen as configuration file for doxygen.
109+
Using the command line, this is done with the following command: doxygen doxyfile.doxygen
110+
111+
112+
7 - Contact Information
113+
-----------------------
114+
115+
For more info about Atmel MCU visit http://www.atmel.com/products/microcontrollers/default.aspx or contact support through the http://support.atmel.no/ site.
116+
The support site also have a Frequently Asked Questions page with the most common questions.
117+
118+
ASF bugs or enhancement requests can be reported in the ASF Bug Tracker (http://asf.atmel.com/bugzilla/).
119+
120+
121+
8 - Community Information
122+
-------------------------
123+
124+
Users can find an ASF forum (http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewforum&f=21) on AVRfreaks for AVR users or on http://www.at91.com/ for SAM users.
125+
This forum can be used to have an open discussion about usage, development, bugs, fixes, improvements, etc.

atmel-samd/frozentest.mpy

255 Bytes
Binary file not shown.

atmel-samd/frozentest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
print('uPy')
2+
print('a long string that is not interned')
3+
print('a string that has unicode αβγ chars')
4+
print(b'bytes 1234\x01')
5+
print(123456789)
6+
for i in range(4):
7+
print(i)

0 commit comments

Comments
 (0)