Common Pitfalls designing a custom board?

If you made your own board, post here, unless you built a Maple or Maple mini clone etc
mariusTe
Posts: 6
Joined: Mon Nov 29, 2021 2:05 pm

Common Pitfalls designing a custom board?

Post by mariusTe »

Hi there,

I'm currently designing a small test board to develop software for an upcoming larger PCB design I want to make.
In my work I usually use CubeMX to select all the Periphery I want and the software engineers implement these modes in firmware. For this non-work project I have to do every thing myself of course :) .
My question then: are there any pitfalls I should look out for when designing my first Arduino on STM32 board or can I just go ahead an load up all the GPIOs as I would when designing a non-Arduino STM32 board? Are there things which would require a large amount of tinkering within the libraries to get going.

MCU: STM32L052R8T6
Periphery: 2xUART, 2xI2C, 1xSPI (6 ICs daisy-chained), 11 Analog channels, 4 Interrupt inputs, a few digital outputs
Programming via SWD (ST-Link v3), I will design a different board to experiment with USB
Clock source: 32kHz LSI

Sorry for the messy schematic, it is an early draft and I haven't calculated all the resistor and capacitor values yet (EDIT: never mind, to hit the file size limit I had to cut away everything non-essential)
Schematic MCU Part 1
Schematic MCU Part 1
schematic1.png (76.15 KiB) Viewed 5508 times
Schematic MCU Part 2
Schematic MCU Part 2
schematic2.png (83.31 KiB) Viewed 5508 times
Pinmapping MCU Basic
Pinmapping MCU Basic
Pinmapping.png (19.22 KiB) Viewed 5508 times
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Common Pitfalls designing a custom board?

Post by mrburnette »

In the old forum, a number of members were interested in their own boards. I seem to remember that a number of challenges were encountered and discussed. Feel free to explore:
https://www.google.com/search?q=custom+ ... oforum.com

Added:
The origional Maple Mini was a 4-layered board as it had separate "analog groundplane" and separate "digital groundplane" to provide enhanced analog performance which is not available with 2-sided only boards.
ag123
Posts: 1653
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Common Pitfalls designing a custom board?

Post by ag123 »

if you are familiar with cube mx, you could start with cube mx then 'port' it across into stm32duino.
the catch is cube mx tend to make leaner firmware than using the core as cube mx generates firmware stripped down to only the peripherals you configure.

among the things, choose a chip with usb support, in particular that can use usb-cdc-serial.
this could make things much easier as Serial.print() works. But that usb driver do consume flash and memory.
for the STM core try to start with things that has more flash and sram, at this stage, it is still trying to keep the various 'supported' devices/boards across the stm series from f0,l0 to f7,h7 and even mp1 running. this is a herculean effort. but that it leaves little room for 'optimization' as it is really 'hand made' software / firmware.
having that room would likely help as compared to using a small device with little memory and flash, it is analogous to squeezing an elephant in a small room. it can be quite challenging if ram and flash is insufficient.
I'd suggest trying to find one of those Nucleo boards, preferably existing 'supported' ones and try them out with STM core.
If it isn't 'supported', it is basically adding a variant for it, that can be done by using an existing board that is close enough as an example/starting point.
making that variant is a decent learning experience for a board not already on the list
https://github.com/stm32duino/Arduino_Core_STM32
the main things are the PLL and clock configurations, pinmaps etc.
using a Nucleo board that is close to, preferably same mcu as your mcu for the custom board would let you create a variant for a board that has been designed and working.
This certainly saves some tedious, possibly costly rework for a real custom board.
And it makes it more likely that the custom board works 'out of the box' at the first attempt. not easy to achieve really.

off-topic, STM core has nearly become, i've got this board, how do i use stm32duino (this is quite true for '3d printer boards'), oh erm. well, it is nearly a flattery but close for stm32duino to have achieved this far :lol:
mariusTe
Posts: 6
Joined: Mon Nov 29, 2021 2:05 pm

Re: Common Pitfalls designing a custom board?

Post by mariusTe »

Thank you for the advice, I'll have a deeper look at it in the weekend.
It seems that my hope that arduino on stm32 will work out of the box for the MCU were a bit ambitious. It may be necessary that I have to prgramm the board without arduino.
I chose the chip because it was one of the few available to buy and listed on the compatibility list. I'll know more when I finish and order my custom board in a few weeks
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Common Pitfalls designing a custom board?

Post by mrburnette »

mariusTe wrote: Tue Nov 30, 2021 3:18 am It may be necessary that I have to prgramm the board without arduino.
...
Arduino is really not well understood; it is just a bunch of JAVA code and script files with a little code manipulation (like automatic function prototyping.) The STM32 implementation is a set of wrappers around industrial-strength commercial code.


https://github.com/stm32duino/Arduino_Core_STM32
This repo adds the support of STM32 MCU in Arduino IDE.

This porting is based on:

STM32Cube MCU Packages including:
- The HAL hardware abstraction layer, enabling portability between different STM32 devices via standardized API calls
- The Low-Layer (LL) APIs, a light-weight, optimized, expert oriented set of APIs designed for both performance and runtime efficiency
- CMSIS device definition for STM32

CMSIS: Cortex Microcontroller Software Interface Standard (CMSIS) is a vendor-independent hardware abstraction layer for the Cortex®-M processor series and defines generic tool interfaces. It has been packaged as a module for Arduino IDE: https://github.com/stm32duino/ArduinoModule-CMSIS

GNU Arm Embedded Toolchain: Arm Embedded GCC compiler, libraries and other GNU tools necessary for bare-metal software development on devices based on the Arm Cortex-M. Packages are provided thanks The xPack GNU Arm Embedded GCC: https://github.com/xpack-dev-tools/arm- ... -gcc-xpack
mariusTe
Posts: 6
Joined: Mon Nov 29, 2021 2:05 pm

Re: Common Pitfalls designing a custom board?

Post by mariusTe »

mrburnette wrote: Tue Nov 30, 2021 8:10 pm
Arduino is really not well understood;
Maybe. For me arduino is just a hardware abstraction layer + IDE which is much more pleasant to use (for me) than STs‘ own HAL + IDE
racemaniac
Posts: 20
Joined: Wed Dec 18, 2019 6:53 pm

Re: Common Pitfalls designing a custom board?

Post by racemaniac »

I'm not sure if there are any real big pitfalls for custom design boards.

The best advice probably is looking at the schematics of existing boards for examples of whatever you want to add to your board, that's always a good start. One of the issues i had on one of my first boards was not enough capacitors near things that draw a bit of current, sometimes causing supply issues, but i think i see enough of those on your schematic :).

And in the end, the best advice is probably don't get stuck in designing it too long, having 5 prototypes fabricated in china & sent to you is pretty cheap these days, and testing the actual thing will help you find any issues very quickly. You rarely get there without revisions :)
mariusTe
Posts: 6
Joined: Mon Nov 29, 2021 2:05 pm

Re: Common Pitfalls designing a custom board?

Post by mariusTe »

I agree with the concept of rapid prototyping. In this case however I hope to limit the „rounds“ to two or three: one test board to develop software and one final pcb with its >300 components. The cost is really low for the pcbs but the stecil and for now the microprocessors are quite costly :?
mariusTe
Posts: 6
Joined: Mon Nov 29, 2021 2:05 pm

Re: Common Pitfalls designing a custom board?

Post by mariusTe »

Thank you all for the advice, I got the impression that there aren’t really any showstoppers. This week I’ll try a nucleo board with arduino and test some peripheries. When I’m comfortable with the software experience and tool chain I will order my board
Best regards
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Common Pitfalls designing a custom board?

Post by mrburnette »

mariusTe wrote: Wed Dec 01, 2021 2:58 am ...
Maybe. For me arduino is just a hardware abstraction layer + IDE which is much more pleasant to use (for me) than STs‘ own HAL + IDE
I think if carefully considered, it is a software (simplified commands, functions similar to BASIC) and hardware is not abstracted but simplified into basic functions. Even the pinout nomenclature has taken on simple naming conventions such as D0, D1, D2 ... and A0, A1, A2, A3, etc.

The IDE is pretty basic; some people like it, others make do, others us an external editor like Notepad++. Automatic prototyping is a mixed bag IMO; I often do my own function prototyping as it helps me think.

There is a penalty in performance and codesize to be paid to code in Arduino on the STM32 platform; Frederic has some numbers somewhere; but I have had no particular annoyances with the HAL wrappers.
Post Reply

Return to “Custom design boards”