Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42 - Page 1
Forum section: electronics / general

author: technix
author_rank: Super Contributor
timestamp: April 18, 2018, 04:56:30 pm
content: So far I managed to get ARM's reference implementation of CMSIS-DAP, taken directly from their DAPlink repository, to build and seemingly properly recognize with Keil v5 with my STM32F042K6T6 board.Functionality: SWD is not working, JTAG is working but problematic. (Maybe I should increase the JTAG node count?)Code size: So far the code size is about 23kB with -Og optimization (instead of the aggressive -Os) and RAM usage is about 4kB. Do keep in mind that the chip have only 6kB SRAM and 32kB Flash, so this can be a constraint. I did not use Keil RTE, RTX or STM32CubeMX. This is entirely bare metal with a small USB Stack written by dmitrystu and direct register manipulation for GPIO.Target: I need two variants of the same firmware: one with SWO and MSC intended for the independent DAP42 debug probe, ant another without SWO or MSC but still have full SWJ and CDC for the STM32F042F6 based DAP42 Embedded variant.

author: andyturk
author_rank: Frequent Contributor
timestamp: April 18, 2018, 07:18:19 pm
content: Somebody write a USB stack in assembly? WTF?https://github.com/dmitrystu/libusb_stm32

author: technix
author_rank: Super Contributor
timestamp: April 18, 2018, 08:14:22 pm
content: Quote from: andyturk on April 18, 2018, 07:18:19 pmThat is the USB stack I am using, just not the ASM version. (Actually I also contributed some code to that one.)

author: andyturk
author_rank: Frequent Contributor
timestamp: April 18, 2018, 11:42:53 pm
content: I haven't looked at the code carefully, but is it possible to run this stack with just what's in the .c files?I'd do almost anything to get away from ST's bloated implementation, except maybe dropping in a large chunk of someone else's hand-written assembly.

author: devan
author_rank: Contributor
timestamp: April 19, 2018, 12:00:31 am
content: FYI, if you just wanted the reference implementation for CMSIS-DAP, you can also get it from the ARM CMSIS orCMSIS-5repo. The CMSIS-5 implementation looks like it would be gcc/clang compatible without any modifications.I'm a bit skeptical that a bulletproof MSC implementation will fit in the remaining 8-16K flash available, but I would love to be proven wrong. I've seen some very compactMSC bootloaders, but those don't have the code overhead of running a flash algorithm over SWD/JTAG vs direct writes to local registers.Personally, I'm rooting forWebUSBsupport as a better way to support no-installation-needed development board flashing (and eventually debugging).

author: SiliconWizard
author_rank: Super Contributor
timestamp: April 19, 2018, 01:42:27 am
content: I remember using a Cypress FX2 in one project. Just a 8051-type 8-bitter with an USB core. There was only 16KBytes of RAM for both code and data, and we could fit all of our application code including USB handling in like 12K and there was about 4K available for data. All coded in C using SDCC. Good ol' non-bloated times.

author: technix
author_rank: Super Contributor
timestamp: April 19, 2018, 04:47:38 am
content: Quote from: andyturk on April 18, 2018, 11:42:53 pmYes. When you drop that code into your project, only one C file gets compiled anyway.Quote from: devan on April 19, 2018, 12:00:31 amMaybe I should rebase...Quote from: devan on April 19, 2018, 12:00:31 amWell there is still 12kB Flash available, and an external SPI Flash to back the storage.Quote from: SiliconWizard on April 19, 2018, 01:42:27 amCan CMSIS-DAP even run on 8051? Otherwise it would be interesting.

author: janekm
author_rank: Unknown
timestamp: April 20, 2018, 06:01:50 am
content: Quote from: andyturk on April 18, 2018, 07:18:19 pmI wonder... the assembly has comments, but somehow doesn't quite look like human-written assembly to me? Did someone just add comments to the assembly written by a compiler (but why?)?

author: SiliconWizard
author_rank: Super Contributor
timestamp: April 20, 2018, 08:01:47 am
content: Quote from: technix on April 19, 2018, 04:47:38 amNope, CMSIS is targetted at ARM Cortex cores only.

author: technix
author_rank: Super Contributor
timestamp: April 20, 2018, 02:56:05 pm
content: Quote from: janekm on April 20, 2018, 06:01:50 amIt seem to me that the assembly code is modified from GCC's output, hence the comments (added in modification) and machine-looking code (original gcc -Os -E output.)

author: SiliconWizard
author_rank: Super Contributor
timestamp: April 20, 2018, 03:10:10 pm
content: Quote from: technix on April 20, 2018, 02:56:05 pmYes, that's what it looks like to me as well. Whether it's just prettified assembly without any modification, or whether the guy hand-optimized stuff, I don't know.

author: josip
author_rank: Regular Contributor
timestamp: April 21, 2018, 11:17:20 am
content: Quote from: SiliconWizard on April 19, 2018, 01:42:27 amMy CDC bootloader for MSP4305xx devices with USB hardware module fit to 2 Kbyte. Bootloader interface / commands + USB stack + AES decryption, total 2 KByte, written in assembler.

author: technix
author_rank: Super Contributor
timestamp: April 21, 2018, 01:39:20 pm
content: Quote from: josip on April 21, 2018, 11:17:20 amFor me I have STM32F042 USB CDC in about 8kB of only C, using that exact USB library.