Commit Graph

77 Commits

Author SHA1 Message Date
Oliver Smith e6e77399d6 firmware/Makefile: don't use distribution's CFLAGS
Set CFLAGS on top of the Makefile, to avoid using the distribution's
default CFLAGS. In debian testing and unstable, -fcf-protection was
recently added to the default CFLAGS, but it cannot be used with the
cross compiler:

  [COMPILING libosmocore/source/backtrace.c]
  cc1: error: '-fcf-protection=full' is not supported for this target
  make[2]: *** [Makefile:270: obj/simtrace/flash_backtrace.o] Error 1

Change-Id: I5f7cd0402f9bb85dd600204fdf8855773ddbeb70
2023-09-13 15:33:48 +00:00
Eric Wild cb655f9774 firmware: add crc stub to all dfu apps to ensure reliable loading
DFU flashing of apps sometimes aborts, and although rare this leads to
broken devices if no boot button or serial/jtag access exists, because
the bootloader will keep trying to start a half-flashed app that then
crashes at some point.

The easiest fix that works with existing bootloaders is to prepend a
small 512 byte stub that calculcates the crc and compares it with the
crc calculated at build time, and then either starts the actual app, or
sets the dfu flag and resets. This ensures we either have a working,
running app, or end up in the bootloader, ready to flash again.

For obvious reasons this only applies to dfu apps, and not to flash
targets like the actual bootloader itself.

Change-Id: Id6df0486c8b779889d21800dc2441b3aa9af8a5f
2021-12-15 14:04:20 +00:00
Eric Wild 61b4aad46f firmware: remove dfu-dfu default target
It's useless, since blupdate does the same thing, just much faster and
easier.

Change-Id: I86dddfacea2e35f4d5a7f23ee4b3d12e3f1d35f1
2021-11-24 17:22:01 +00:00
Eric Wild c85f52d5d5 firmware: drop cref printing
No one reads this, no one wants to know this.

Change-Id: Ie2281e207164f82d8ee29bd596a5593c22aaf198
2021-11-01 14:35:14 +01:00
Eric Wild a7e306f745 firmware: add bootloader update "app"
This bl updater can be flashed as app and will update the bootloader and
then
delete itself before resetting the sam3, so the device will end up in
the newly
updated dfu bootloader afterwards, without having to press the
bootloader button
or requring any other manual interaction, ready to receive a new
application image.

Building the blupdater requires a previously built dfu-flash bootloader
bin file that
will then be embedded into the app during building.

Related: OS#1704
Related: SYS5061
Change-Id: I53dea57bba790a2ab3245d9483e0ff1c8d19d5e3
2021-11-01 12:03:38 +00:00
Eric Wild a65fb1e319 clang build support
Supposed to be used with https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm
+ distro provided binutils-arm-none-eabi package, might provide better and more reliable
binary sizes, especially for the bootloader.

Just run USE_CLANG=1 make

Change-Id: I1a19f40d44797efad5c46121e73115ed738a095b
2021-10-20 20:03:06 +02:00
Eric Wild 5e82a2a1c6 Revert "firmware: data sections"
This reverts commit e6a76c7bf4.

Might or might not cause weird issues depending on gcc and binutils
versions, let's see if this helps.

Change-Id: I2f593fd5e0f1494aae6b9fcfb2160a6c9168f5b8
2021-10-04 18:05:45 +02:00
Eric Wild 301aec51f7 contrib/jenkins.sh: lower trace to make bl fit
We keep running out of rom space, so reduce tracing to nothing for alle
dfu targets, and let's hope newer gcc versions stop producing more
code...

Change-Id: I7d2947c84097035bed00ad489a175d614b4c388e
2021-10-04 15:07:44 +00:00
Eric Wild 34317c1f32 firmware: proper makefile deps
Single threaded evaluation is (assumed to be!) left to right, depth
first - but with concurrent make using -j this breaks, because the
actual usb string header is generated after the attempt to concurrently
compile the code that needs it, since there is no explicit order among
the all: dependencies.

This is fixed by properly adding a dependency on that header.

Change-Id: I0bdf915deabeda861f6398e654764918e58a64c2
2021-08-02 09:22:46 +00:00
Eric Wild e6a76c7bf4 firmware: data sections
Might or might not be compiler default, but why guess?

Change-Id: Id3da816611afea0858466949dcc47db5e5d5493a
2021-08-02 09:22:46 +00:00
Oliver Smith 878fadd74f firmware: disable stack protector by default
Disable stack protector for all boards/apps by default, not only
qmod-dfu. Use 'make STACK_PROTECTOR=1' to enable.

This was recommened by Eric:
"I'd argue that we do not want this in general, since it adds canaries
to all functions that deal with buffers, and therefore impacts the
overall timing in a non determinstic way depending on inlining and
optimizations, while contributing nothing in non debug builds."

Related: OS#5081
Change-Id: I30ad97f231ea5b401def650bc9adc7e9f2770df0
2021-04-08 12:04:47 +02:00
Oliver Smith 9e0e0ddd5a firmware: qmod-dfu: disable stack protector
Prevent build failure on debian 9, ubuntu 20.04, 20.10, where
bin/qmod-dfu-flash.elf does not fit the ROM.

Fixes: OS#5081
Change-Id: I9fffe4c323094679062428f41a4246b1c1b30ca2
2021-04-07 15:23:55 +02:00
Eric Wild 9316890a39 firmware: allow verbose builds
make V=1 can be used to echo all compilation commands, which is useful
because it allows IDEs to parse the gcc output in oder to properly index
the source files using the actual defines passed to the compiler.

Change-Id: I25c41dff89302a73ddd2a4aaba7cb14912fac3b8
2021-04-04 16:16:24 +00:00
Eric Wild 19cd3b0f71 firmware: do not allow undefined symbols
For some reason undefined symbols were downgraded to warnings, which
means building a firmware that calls missing functions  (= address zero)
was perfectly fine, which of course made development more exciting....

This applies to builtins, too, printf of one char gets downgraded to
putchar, which we don't have, so disable builtins.

Change-Id: I492f41ad4162b9d07b1881ae4aed019db2dff8b5
2021-04-04 16:16:24 +00:00
Oliver Smith 1031d9b884 firmware: create duplicate files for upload only
Don't create copies of firmware files with version strings appended in
the normal build. Only do this before uploading the firmware files.

I have verified that "make" before this change and
"make; contrib/prepare_upload.sh" after produce the same files.

Close: OS#4413
Change-Id: I118a4ff397a178281c26a6b98112fa66b6f049ab
2021-03-05 15:38:48 +01:00
Oliver Smith 09c3d45d6e firmware/Makefile: fix UNKNOWN in OBS packages
Fix having the version set to UNKNOWN in all packages built by OBS. The
osmo-ci.git scripts generating the source packages to be built by OBS
generate a ".tarball-version" file with a version string like
"0.7.0.70-657c", but it did not get used because the path was wrong.

Related: OS#4413
Related: https://osmocom.org/projects/cellular-infrastructure/wiki/Git-version-gen
Change-Id: Ic0b06011a604beec7c1c907c2c6e4ae927456e2e
2021-03-05 12:41:22 +01:00
Harald Welte 1afb70a69d firmware: fix builds with gcc stack smashing protection enabled
On Ubuntu 20.04 when builiding dpkg packages, even when cross-compiling
firmware, gcc stack smashing protection is enabled.  Let's provide what
is minimally required in order to sucessfully complete builds on such
platforms.

Change-Id: Ic2f68f16b0730e7b5db17c30effc29a2909d1997
Closes: OS#4687
2020-08-05 11:59:26 +02:00
Kevin Redon b6e2f0f8e7 DFU: add DFU application
this adds the DFU as application, allowing to flash the bootloader.
a USB DFU alternative is added to flash the bootloader partition.

when the DFU is started as bootloader, the partition/alternative
to flash the bootloader is marked as "not available", and
ineffective.
the same happens for the application partition when DFU is started
as application.

this distinction is make at compile time, not at runtime, because
of size restrictions (the bootloader was already close to the
16 kB limit).
*_dfu_flash.bin should not be mixed with *_dfu_dfu.bin.
*_dfu_dfu.bin should be flashed as application using the already
existing DFU bootloader.
once this images is started (as application), the *_dfu_flash.bin
should be flashed as bootloader using the DFU application.

once the DFU bootloader has been flashed, soft resetting
(not re-powering) will cause the bootloader to start, allowing to
flash the application with a normal image (e.g. not DFU),
replacing the DFU application.
this switch to DFU only happens after downloading (e.g. flashing).

it is planned to have the DFU application erase itself after
flashing, but this is currently not implemented.

Change-Id: Ic273bb593a7669111b0219fe301d7897419167c8
2020-01-16 20:35:04 +00:00
Harald Welte e3b2de45c4 firmware: move printing of welcome banner to common function print_banner()
This unifies the printing of the welcome banner, and it also ensures
that all modes print all information (serial number, reset cause).

Furthermore the APP and BOARD #defines from the make environment are
also printed.

Change-Id: I7e6bc05cee4b9ec0fd9a05dc90ce0b26a5763e5a
2020-01-11 17:52:36 +01:00
Kevin Redon 98cf47adba Makefile: add linker option showing memory usage
this will help seeing how much free space is available for the
bootloader (which is restricted to 16 kB)

Change-Id: Ie74a1480c2f340765046be9bdfc3a8c4ba851e9b
2019-12-11 16:13:58 +01:00
Harald Welte 87940f1f83 Build only 'reasonable' combinations of APP/MEMORY
There's no point in building a DFU loeader that is to be flashed
via DFU - nor is there really any need for regular cardem/trace
that can be flahsed directly without DFU.  If anyone needs those,
they can still build them - but let's not confuse the average other
user.

Change-Id: I0abe86c6a942a59e5b2417d0532dffae654d7a18
Closes: OS#4087
2019-12-06 20:08:33 +01:00
Harald Welte 36f888f8b5 Patch actual board name into the USB iProduct string descriptor
"SIMtrace 2 compatible device" is pretty generic.  Let's have the
actual board name inside the string descriptors, giving a more
user friendly experience in case users are issuing 'lsusb' and the
like.

Change-Id: Ibcc338b504bd2a1605e31d7f5eadb7161f547c6a
2019-12-06 19:19:23 +01:00
Harald Welte 0b7e5f3af0 fix baudrate of 'make log'
Change-Id: Id186a594b1ce3ea0cd38f0cb82a99e5d87101433
2019-12-02 19:25:55 +01:00
Kevin Redon 72a62cfdb9 minor: fix spacing
Change-Id: I2f3127c7b276c9726fd0242e3e29be22f9d6255c
2019-12-02 19:25:37 +01:00
Kevin Redon d14970f95b publish: also upload latest
the jenkins script will now upload the versioned output to the
all directory, and a copy named "latest" in the latest directory.

Change-Id: I70114ef8414779e369da5cbf945854c9ace3464e
2019-08-01 17:23:23 +02:00
Harald Welte 155f57abcf firmware: name binaries including their git version number
Change-Id: I4309810368ce4e8e13ede974b67e69ca3f0a6f53
Closes: OS#3452
2019-06-20 18:31:28 +02:00
Kevin Redon 63490361d2 remove unused make define
Change-Id: Ia9ef8ce705803df06cf1e4c3ac9731ce69e5e6c5
2019-05-23 16:34:29 +00:00
Kevin Redon 6228d187da add make DEFINE to remove assert ERASE code
remove code to assert peer ERASE line by default.
see README for more information.

Change-Id: I5f88ecf1e2dcf00c0297597f88dd361a6e088c1e
2019-05-23 16:34:29 +00:00
Harald Welte c394109964 firmware: Enable -Wformat and resolve all related compiler warnings
There have been tons of format-string related bugs in our code which
we never discovered due to disabling -Wformat.  Let's fix that.

Change-Id: I5ec466361bcc526fac1f4897673264ee5af3458b
2018-08-26 10:20:05 +02:00
Harald Welte f7f61cd10f Makefiles: Add "make install" target
Change-Id: Ic6835ce55930c60f909e140878c4abab8628e077
2018-08-26 10:09:43 +02:00
Harald Welte ebe8b2069c Makefile: fix automatic creation of obj directory
since we're using obj/$BOARD, we must use "-p" to create the directory
recursively
2018-06-29 21:44:12 +02:00
Harald Welte c35998e20d Makefile: Disable -Wundef and -Wsign-compare for now
This silences tons of warnings which are making it hard to identify
actual issues when looking at the compiler output.
2017-11-28 20:47:23 +01:00
Harald Welte 8e7fca3255 migrate from req_ctx to msgb
We now generalize the USB communiction and abandon the 'req_ctx'
structure inherited from openpcd.  Instead we use the libosmocore 'msgb'
structure to handle incoming and outgoing USB tranfers.  We also use
linuxlist-based msgb-queues for each endpoint.
2017-05-07 23:09:56 +02:00
Harald Welte 0380d74405 Makefile: remove .p files during 'make clean' 2017-05-07 11:20:40 +02:00
Harald Welte 9457bf765d Makefile: Don't warn about failed inlines 2017-05-07 11:20:24 +02:00
Harald Welte caca0b1e7a Makefile: Add new 'combined' target to build combined DFU+APP image 2017-05-05 23:17:31 +02:00
Harald Welte 912b183b29 qmod: Use different Interface Strings for Modem1+2 / Modem 3+4
This makes it obvious in 'lsusb' and to other software on the USB host
which interface is for which of the modems.
2017-03-06 09:28:13 +01:00
Harald Welte 2363fa0327 Generate USB Strings from apps/*/usb_strings.txt files at compile time
This way we can skip the manually-crafted USB string definitions in the
dfu_desc.c and usb.c files.
2017-03-05 10:16:25 +01:00
Harald Welte adbe72a5ba Makefile: Define APPLICATION_foo BOARD_bar and ENVIRONMENT_baz #defines
This can help us with conditional code
2017-03-02 23:16:01 +01:00
Harald Welte edf9c9d322 Makefile: Optimize for size
This gets the dfu image down from 19 to 11 kBytes, with is well within
the 16kbyte limit for the DFU partition.
2017-02-27 23:24:22 +01:00
Harald Welte 37b6e41f84 move last few files from src_board / include_board 2017-02-27 23:20:38 +01:00
Harald Welte d09829dcc6 Remove newlib dependency, include own stdio/string/assert 2017-02-27 23:00:26 +01:00
Harald Welte d8a003dfd7 Structure build system to build for multiple boards/apps/environments 2017-02-27 22:18:45 +01:00
Harald Welte 3f5e3ddffc Change directory structure to align with Atmel softpack
This way we can easily check with 'diff' for differences in our code and
Atmel softpack.  Also, this layout is more suitable for building various
different firmware images (e.g. factory-test, dfu-loader, main
application) for a variety of different boards (simtrace, owhw, qmod).
2017-02-27 14:24:11 +01:00
Harald Welte 7ed6f3bc37 WIP: Introduce USB DFU code from my at91lib DFU port 2017-02-27 09:28:34 +01:00
Harald Welte aa3b867abb WIP: split main from board-speciic parts 2017-02-26 15:59:56 +01:00
Harald Welte a05ccc9103 build efc.o and flashd.o as part of build process 2017-02-26 15:51:10 +01:00
Harald Welte 6732248f71 Add support for board version reading via ADC 2017-02-10 19:19:48 +01:00
Harald Welte 987f59aa02 Import libosmocore timer infrastructure and use it for PERST
The PERST is thus no longer busy-waiting but starting a timer to release
the PERST after 1ms.
2017-02-04 14:58:45 +01:00
Harald Welte b41598b602 Introudce an include_libosmocore directory and move (updated) linuxlist there 2017-02-04 12:15:58 +01:00