Hanno Braun

SVD files for LPC822/LPC824 are broken

Discussion created by Hanno Braun on Sep 18, 2018
Latest reply on Sep 20, 2018 by jeremyzhou

Hello,

 

a while ago I posted about problems I found in the LPC82x SVD file. I recently noticed that newer SVD files for LPC822 and LPC824 are available via the MCUXpresso SDK Builder, so I tried updating my LPC82x Rust bindings based on the new files.

 

While those new files fix all the errors that I previously reported (thank you!), I found many new problems in them. Some of them are obvious and easy to fix. But a large number of them are subtle, and could lead to subtle bugs in programs that rely on the correctness of those files. For this reason, I will stay away from those files, and recommend anyone who considers using them do the same.

 

As I said before, some of the bugs are obvious and easy to fix. But there's a large number of incorrect reset masks, that I believe could turn into a debugging nightmare for anyone using language bindings based on those files. Here's a list of bugs I found, with links to commits in my work-in-progress branch that fix them (since the LPC822 and LPC824 files are virtually identical, these problems apply to both):

  1. Missing interrupts (commit) - Interrupts are missing that were present in the old file.
  2. Comparator control register (commit) - Wrong field values in comparator control register
  3. MRT0 reset mask (commit) - Incorrect reset masks in MRT0 peripheral.
  4. ADC reset values and masks (commit) - Incorrect reset values and reset masks in ADC peripheral.
  5. ACOMP reset mask (commit) - Incorrect reset mask in ACOMP peripheral.
  6. INPUTMUX reset masks (commit) - Incorrect reset masks in INPUTMUX peripheral.
  7. FLASH_CTRL reset value (commit) - Incorrect reset value in FLASH_CTRL peripheral.
  8. IOCON register block size (commit) - IOCON register block has the wrong size.

Please note that I haven't reviewed these fixes. As I said, this branch is in a work-in-progress state, and I gave up on using the files due to the numerous errors.

 

In addition to the bugs that I fixed in my branch, there are some more problems that I found, but don't have fixes for:

  1. ADC0 is missing a lot of enumerated values that were present in the old file.
  2. INPUTMUX is missing enumerated values that were present in the old file for the INP field in DMA_INMUX_INMUX and the INP_N field in SCT0_INMUX.
  3. The FLASHTIM field in the FLASHCFG register has two reserved values (0x2, 0x3) according to the user manual, but 0x2 is not reserved in the SVD.
  4. The registers in the IOCON peripheral have the wrong names.

 

And lastly, I found something that looked odd in the user manual itself: The TIMER registers in MRT0 have a field called VALUE. According to the user manual, the reset value for that field is 0x00FFFFFF, which looks odd for a 31-bit field. It also contradicts the register overview, which gives a reset value of 0x7FFFFFFF for the register.

 

I'd like to emphasize that all these errors in the reset masks are extremely damaging to my use case. They could cause single bits or groups of bits in registers to have unexpected values. That could lead to really weird bugs that are hard to find, because they are buried in the generated peripheral access code. I hope that it will be possible to fix all these mistakes and get solid versions of these SVD files. I thank NXP for all the effort they've expended on these files so far!

Outcomes