[ATSAMD] How to setup SAMD series build environment?

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
User avatar
water
Posts: 75
Joined: Sun Sep 24, 2017 9:16 am

[ATSAMD] How to setup SAMD series build environment?

Post by water » Mon Apr 26, 2021 8:04 pm

I try to build ATSAMD51 use

Code: Select all

make BOARD=MINISAM_M4
, return error below:
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
mkdir -p build-MINISAM_M4/genhdr
GEN build-MINISAM_M4/genhdr/mpversion.h
GEN build-MINISAM_M4/genhdr/moduledefs.h
GEN build-MINISAM_M4/genhdr/qstr.i.last
In file included from modmachine.c:29:
samd_soc.h:30:10: fatal error: sam.h: No such file or directory
30 | #include "sam.h"
| ^~~~~~~

compilation terminated.
Traceback (most recent call last):
File "/home/mc3/pycode/micropython/ports/samd/../../py/makeqstrdefs.py", line 188, in <module>
preprocess()
File "/home/mc3/pycode/micropython/ports/samd/../../py/makeqstrdefs.py", line 62, in preprocess
for output in p.imap(pp(flags), chunks):
File "/usr/lib64/python3.9/multiprocessing/pool.py", line 870, in next
raise value
File "/usr/lib64/python3.9/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/home/mc3/pycode/micropython/ports/samd/../../py/makeqstrdefs.py", line 46, in run
return subprocess.check_output(args.pp + flags + files)
File "/usr/lib64/python3.9/subprocess.py", line 424, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib64/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['arm-none-eabi-gcc', '-E', '-I.', '-I../..', '-Ibuild-MINISAM_M4', '-Iboards/MINISAM_M4', '-I../../lib/cmsis/inc', '-I../../lib/asf4/samd51/include', '-I../../lib/tinyusb/src', '-Wall', '-Werror', '-std=c99', '-nostdlib', '-mthumb', '-mtune=cortex-m4', '-mcpu=cortex-m4', '-mfpu=fpv4-sp-d16', '-mfloat-abi=hard', '-fsingle-precision-constant', '-Wdouble-promotion', '-DMCU_SAMD51', '-D__SAMD51G19A__', '-Os', '-DNDEBUG', '-fdata-sections', '-ffunction-sections', '-DNO_QSTR', '../../py/objsingleton.c', '../../py/objslice.c', '../../py/objstr.c', '../../py/objstrunicode.c', '../../py/objstringio.c', '../../py/objtuple.c', '../../py/objtype.c', '../../py/objzip.c', '../../py/opmethods.c', '../../py/sequence.c', '../../py/stream.c', '../../py/binary.c', '../../py/builtinimport.c', '../../py/builtinevex.c', '../../py/builtinhelp.c', '../../py/modarray.c', '../../py/modbuiltins.c', '../../py/modcollections.c', '../../py/modgc.c', '../../py/modio.c', '../../py/modmath.c', '../../py/modcmath.c', '../../py/modmicropython.c', '../../py/modstruct.c', '../../py/modsys.c', '../../py/moduerrno.c', '../../py/modthread.c', '../../py/vm.c', '../../py/bc.c', '../../py/showbc.c', '../../py/repl.c', '../../py/smallint.c', '../../py/frozenmod.c', '../../extmod/moduasyncio.c', '../../extmod/moductypes.c', '../../extmod/modujson.c', '../../extmod/modure.c', '../../extmod/moduzlib.c', '../../extmod/moduheapq.c', '../../extmod/modutimeq.c', '../../extmod/moduhashlib.c', '../../extmod/moducryptolib.c', '../../extmod/modubinascii.c', '../../extmod/virtpin.c', '../../extmod/machine_mem.c', '../../extmod/machine_pinbase.c', '../../extmod/machine_signal.c', '../../extmod/machine_pulse.c', '../../extmod/machine_i2c.c', '../../extmod/machine_spi.c', '../../extmod/modbluetooth.c', '../../extmod/modussl_axtls.c', '../../extmod/modussl_mbedtls.c', '../../extmod/modurandom.c', '../../extmod/moduselect.c', '../../extmod/moduwebsocket.c', '../../extmod/modwebrepl.c', '../../extmod/modframebuf.c', '../../extmod/vfs.c', '../../extmod/vfs_blockdev.c', '../../extmod/vfs_reader.c', '../../extmod/vfs_posix.c', '../../extmod/vfs_posix_file.c', '../../extmod/vfs_fat.c', '../../extmod/vfs_fat_diskio.c', '../../extmod/vfs_fat_file.c', '../../extmod/vfs_lfs.c', '../../extmod/utime_mphal.c', '../../extmod/uos_dupterm.c', '../../lib/embed/abort_.c', '../../lib/utils/printf.c', 'build-MINISAM_M4/genhdr/moduledefs.h', 'modutime.c', 'modmachine.c', 'boards/MINISAM_M4/mpconfigboard.h', '../../py/mpconfig.h', 'mpconfigport.h']' returned non-zero exit status 1.
make: *** [../../py/mkrules.mk:105: build-MINISAM_M4/genhdr/qstr.i.last] Error 1
make: *** Deleting file 'build-MINISAM_M4/genhdr/qstr.i.last'
Which software need to install and setup to build ATSAMD series? Is it have simple instruction?
Last edited by water on Wed Apr 28, 2021 7:27 am, edited 2 times in total.

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: How to setup SAMD series build environment?

Post by scruss » Mon Apr 26, 2021 8:50 pm

Looks like you forgot to

Code: Select all

make submodules
from the ports/samd folder.

There's a bit about building here: viewtopic.php?f=12&t=7965&p=56716#p56711

Note that the SAMD ports have no hardware access yet, so they're not very useful.

User avatar
water
Posts: 75
Joined: Sun Sep 24, 2017 9:16 am

Re: How to setup SAMD series build environment?

Post by water » Mon Apr 26, 2021 9:55 pm

Code: Select all

make submodules
from ports/samd
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Updating submodules: lib/asf4 lib/tinyusb

Code: Select all

make BOARD=ADAFRUIT_ITSYBITSY_M4_EXPRESS
The error above appear still.
But I success build some STM32 at same environment.

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: How to setup SAMD series build environment?

Post by scruss » Tue Apr 27, 2021 1:47 am

I just did exactly the same, and was successful:

Code: Select all

make BOARD=ADAFRUIT_ITSYBITSY_M4_EXPRESS
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
mkdir -p build-ADAFRUIT_ITSYBITSY_M4_EXPRESS/genhdr
GEN build-ADAFRUIT_ITSYBITSY_M4_EXPRESS/genhdr/mpversion.h
GEN build-ADAFRUIT_ITSYBITSY_M4_EXPRESS/genhdr/moduledefs.h
GEN build-ADAFRUIT_ITSYBITSY_M4_EXPRESS/genhdr/qstr.i.last
GEN build-ADAFRUIT_ITSYBITSY_M4_EXPRESS/genhdr/qstr.split
GEN build-ADAFRUIT_ITSYBITSY_M4_EXPRESS/genhdr/qstrdefs.collected.h
QSTR updated
 …
CC ../../lib/tinyusb/src/device/usbd_control.c
CC ../../lib/tinyusb/src/portable/microchip/samd/dcd_samd.c
CC ../../lib/tinyusb/src/tusb.c
CC ../../lib/utils/gchelper_native.c
CC ../../lib/utils/pyexec.c
CC ../../lib/utils/stdout_helpers.c
AS ../../lib/utils/gchelper_m3.s
LINK build-ADAFRUIT_ITSYBITSY_M4_EXPRESS/firmware.elf
   text	   data	    bss	    dec	    hex	filename
 101832	     24	   1328	 103184	  19310	build-ADAFRUIT_ITSYBITSY_M4_EXPRESS/firmware.elf
Converting to uf2, output size: 203776, start address: 0x4000
Wrote 203776 bytes to build-ADAFRUIT_ITSYBITSY_M4_EXPRESS/firmware.uf2.
If it's giving the same error, are you missing:

Code: Select all

../../lib/asf4/samd51/include/sam.h
../../lib/asf4/samd21/include/sam.h
?

User avatar
water
Posts: 75
Joined: Sun Sep 24, 2017 9:16 am

Re: How to setup SAMD series build environment?

Post by water » Tue Apr 27, 2021 2:49 pm

Solved, lib/asf4 folder empty, execute

Code: Select all

git submodule update --init lib/asf4
build pass, but I execute

Code: Select all

git submodule update --init --recursive
from micropython root folder before, why lib/asf4 folder is empty?

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: How to setup SAMD series build environment?

Post by scruss » Tue Apr 27, 2021 3:47 pm

No real idea, sorry. Until recently, issuing --recursive would tend to pull in multiple copies of each library for each port. This took far too long.

Good luck working on the SAMD chips. It's kind of annoying that Adafruit's Circuitpython forked off with all the SAMD code coming after.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: How to setup SAMD series build environment?

Post by dhylands » Tue Apr 27, 2021 4:49 pm

The lib/asf4 directory isn't empty for me.

You might want to try starting over with a fresh micropython tree. If I do the following:

Code: Select all

git clone https://github.com/micropython/micropython micropython2
cd micropython2
git submodule update --init --recursive
then I wind up with the following in lib/asf4:

Code: Select all

$ ls lib/asf4/
README.md  samd21/    samd51/    tools/

Post Reply