Author Topic: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42  (Read 3393 times)

0 Members and 1 Guest are viewing this topic.

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
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.
« Last Edit: April 18, 2018, 04:58:35 pm by technix »
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42
« Reply #1 on: April 18, 2018, 07:18:19 pm »
Somebody write a USB stack in assembly? WTF?

https://github.com/dmitrystu/libusb_stm32
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42
« Reply #2 on: April 18, 2018, 08:14:22 pm »
Somebody write a USB stack in assembly? WTF?

https://github.com/dmitrystu/libusb_stm32
That is the USB stack I am using, just not the ASM version. (Actually I also contributed some code to that one.)
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42
« Reply #3 on: April 18, 2018, 11:42:53 pm »
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.
 

Offline devan

  • Contributor
  • Posts: 13
  • Country: us
Re: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42
« Reply #4 on: April 19, 2018, 12:00:31 am »
FYI, if you just wanted the reference implementation for CMSIS-DAP, you can also get it from the ARM CMSIS or CMSIS-5 repo. 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 compact MSC 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 for WebUSB support as a better way to support no-installation-needed development board flashing (and eventually debugging).
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14297
  • Country: fr
Re: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42
« Reply #5 on: April 19, 2018, 01:42:27 am »
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. :popcorn:
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42
« Reply #6 on: April 19, 2018, 04:47:38 am »
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.
Yes. When you drop that code into your project, only one C file gets compiled anyway.

FYI, if you just wanted the reference implementation for CMSIS-DAP, you can also get it from the ARM CMSIS or CMSIS-5 repo. The CMSIS-5 implementation looks like it would be gcc/clang compatible without any modifications.
Maybe I should rebase...

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 compact MSC 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 for WebUSB support as a better way to support no-installation-needed development board flashing (and eventually debugging).
Well there is still 12kB Flash available, and an external SPI Flash to back the storage.

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. :popcorn:
Can CMSIS-DAP even run on 8051? Otherwise it would be interesting.
 

Offline janekm

  • Supporter
  • ****
  • Posts: 515
  • Country: gb
Re: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42
« Reply #7 on: April 20, 2018, 06:01:50 am »
Somebody write a USB stack in assembly? WTF?

https://github.com/dmitrystu/libusb_stm32

I 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?)?
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14297
  • Country: fr
Re: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42
« Reply #8 on: April 20, 2018, 08:01:47 am »
Can CMSIS-DAP even run on 8051? Otherwise it would be interesting.

Nope, CMSIS is targetted at ARM Cortex cores only.

 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42
« Reply #9 on: April 20, 2018, 02:56:05 pm »
Somebody write a USB stack in assembly? WTF?

https://github.com/dmitrystu/libusb_stm32

I 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?)?
It 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.)
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14297
  • Country: fr
Re: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42
« Reply #10 on: April 20, 2018, 03:10:10 pm »
Somebody write a USB stack in assembly? WTF?

https://github.com/dmitrystu/libusb_stm32

I 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?)?
It 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.)

Yes, 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.
 

Offline josip

  • Regular Contributor
  • *
  • Posts: 149
  • Country: hr
Re: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42
« Reply #11 on: April 21, 2018, 11:17:20 am »
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. :popcorn:

My 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.
« Last Edit: April 21, 2018, 11:20:08 am by josip »
 

Offline technixTopic starter

  • Super Contributor
  • ***
  • Posts: 3507
  • Country: cn
  • From Shanghai With Love
    • My Untitled Blog
Re: Ramble: state of the matters with CMSIS-DAP on a small MCU - DAP42
« Reply #12 on: April 21, 2018, 01:39:20 pm »
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. :popcorn:

My 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.
For me I have STM32F042 USB CDC in about 8kB of only C, using that exact USB library.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf