Portable ARM Device

Portable STM32F103 Hardware platform for password/bitcoin keeper, oscilloscope, data logger, game etc.

Similar projects worth following
Most of the projects I have in mind involve a microcontroller, LCD, some buttons, a power source, some I/O and optional mass storage or USB. These $2 MP3 player comes with most of these features, I'll need to replace the PCB with a STM32F103.

While shopping for parts for my next project, I came across these $2 MP3 players from China. They are about 2AA batteries in size. It has all the I/O I'll ever need in a project.  It even comes in an inconspicuous injection molded case making easy to hide your gadget/key/bitcoin keeper in plain sight.

There is already a project: China cheap MP3 player hack . In my case, I would upgrade from the STM32F030 which is my usual favorite to STM32F103 with native USB interface, dual ADC, dual SPI and a lot more memory.

STM32F103 is used in Blue Pill breakout board and can be found for around $2 from China with some minor differences.


  • STM32F103 64kB FLASH, 20kB RAM, up to 72MHz
  • Mini-USB: USB 1.1 device, charging
  • 128x64 LCD
  • Micro SD slot for SD/SDHC.
  • 3.5mm Stereo - multiple I/O functions are available
    e.g. 3.3V TTL serial, ADC, PWM, I2C and serial bootstrap.
  • 5 push buttons, On/Off switch
  • ~100mA Hr LiPO battery,  LTC4054 charger.


Low power design

The device is powered from internal Li-ion battery.  LTC4054 is used for charging the battery from USB. LDO is used to power the main circuits.  The RTC and backup RAM location are backup from the battery. A pair of silicon diodes is used to drop the battery voltage down as they consume no quiescent current vs a LDO.

From Elm-Chan: How to Use MMC/SDC

MicroSD can draw a lot of current and introduce a droop during hot-insertion.  This can reset the microcontroller or affect results of ADC. The XC6206P332MR and other ultra low quiescent current LDO make compromises for low bandwidth/transient response. It has a slow recovery time for a sudden load.  Previously I have seen much less droop using a switch mode supply with a fast transient response.

While you can pile lot of passives to undo the manufacturer's design decision on $0.04 parts, it is cheaper and takes much less space to simply use 2 separate supplies for the microcontroller and the MicroSD.

I wired 4 GPIO in parallel (saving one MOSFET) to control the power to the LCD backlight (probably around 20mA).


A diode clamp is used for input protection.  Two series resistors are used as current limit and the signals are clamped a diode drop above the zener voltage.  The zener is pre-biased by R4 to reduce the load on the inputs below the threshold.  C2 reduce the AC impedance.

The protection circuit can be altered for clamping to 3.3V rail by replacing D1, D2 with use schottky diodes, D3 depopulated and relacing R4 with 0R.

Libraries that needed to be ported/written

Reference bookmarks

Open source password/bitcoin keeper

Read more »

  • Masks and other useful tricks in Eagle CAD

    K.C. Lee04/29/2018 at 14:57 0 comments

    The default DRC file for OSH Park does not have solder mask for pads or vias. If you want to have a solder mask over your vias, you can change "limit" to the maximum via size that you want solder mask:

    Here are some of the layers in Eagle that you might not have cared about:

    Stop MasktStop, bStopArea without solder mask. e.g. pads, contacts
    RestricttRestrict, bRestrictArea not copper pours/traces allowed.
    Keep outtKeepout, bKeepoutArea with no components allowed.
    Cream masktCream, bCreamArea where solder paste is applied
    (for making SMT footprints)

    Here is how I use them for making PCB footprint for a Dome momentary buttons.

    I normally have all my vias with solder mask on, so I want to selectively override the vias inside the dome footprint.  To change the option, simply select the via and right click for "Properties"

    Select the "Stop" to add a stop mask for the via (i.e. leave the copper bare).  Notice the difference between my regular vias (without the shade areas) and the highlighted one.

    Eagle complains if I draw a via directly over the center of the dome button as it overlaps the "pin" for the footprint.  So I place a via off center and move it afterwards.


    • I draw a donut circle (in tDocument layer)over my vias so that I know how much clearance I need to leave around it.
    • I define my cream layer to reduce the amount of solder paste (60-70%) for my QFN footprints.  This fixes the issue of the QFN package floating on the solder paste of the center pad.
    • Draw a thick line in Restrict layer for high voltage vs low voltage circuit isolation.  The width of the line should the creepage requirement for the working voltage.  DRC will warn you about violation and copper pour would avoid the area.
    • Clearly label the high voltage and low voltage areas on your PCB.  It might save a life.

    See here for an explanation

    • Add the Restrict in your opto-isolators/relays/Ethernet transformer footprints. This help DRC flag your isolation violations.  Don't run traces between rows of pins between a high voltage and low voltage circuit.

  • Schematic Layout V6

    K.C. Lee04/28/2018 at 13:18 0 comments

    Not a whole lot have been done as I had a lot of bad luck lately.  I am procrastinating about working on my tax return (due end of the month), so that's why I am working on this layout instead. This is the 6th iteration of the layout.  I don't know if this will be the last.  Here is what it looks like right now before final DRC and clean up.

    It is not an easy layout as I have little freedom on the parts placement.  There are some congested areas around the microcontroller. I have to use OSH Park with their denser 10 mils via for the uC breakout even though their 0.031" board is a bit too thick to match the original PCB. 

    I opted to remove one of the alignment post from the 10-pin mini-USB connector because it is in a different location than the regular one and it interferes with the right button.

    Maybe it is just me as I don't simply route traces until all the air wires disappears and call it a day.  I try to preserve signal quality by minimizing the return current loop areas.  i.e. making sure that there is a ground or power very near where the high speed signal traces are going.  So what it means is that I am routing on one layer as much as I can.

    This project is no longer a fork from a similar one on HaD as I have reworked all the PCB outlines, specific parts placement from scratch based on my own PCB high resolution scan.  The push buttons have the proper stop mask to expose the ENIG plating for the contacts.

    Looks like summer this year is going to be bad too for working on projects. They are going to be a lot of jack hammering on the outside wall of my apartment building again for at least 9 weeks.  They hammered out the concrete, added extra rebars and repoured my bedroom wall last summer.  There are still a bit of work left on the other wall.

  • 10 pins Mini-USB connector

    K.C. Lee02/02/2018 at 03:10 0 comments

    SWD is one of the things I would like to have available without having to open up the case all the time. One way to do that is to fool around with the ID pin and share pins with USB.

    I am tempted to use those 10 pin Mini-USB connectors which are used in some cameras for composite video and audio.  They are backwards compatible with regular 5-pin USB plugs. 

    I have ordered 10 receptacle from here and 10 plugs from here. I found a datasheet for something that matches the receptacle here. Unfortunately that means pushing back this project for quite a bit as I want to confirm the footprints before committing to a final PCB design.  I guess I could work a bit on the firmware for the time being.

    Aliexpress called receptacle a Type-B while the datasheet call it Philips style.  

    Looks like the receptacle could be a Mini-AB which could accommodate the Mini-B plug which is the only style still used.

    The plastic panel needs to be filed.

  • Teardown of 2nd batch MP3 player

    K.C. Lee01/30/2018 at 19:26 0 comments

    The 2nd batch of MP3 players arrived via Kyrgyzstan.  Canada Post have decided to raise the postage fee from China Post starting from 2018, so I would expect to see a lot more creative logistic shipping routes in the future.  Canada Post service has deteriorated over the past few years.

    This MP3 player is a lot easier to disassemble.  There are two self tapping screws holding down the plastic panel in the right side.

    Two pegs from the panel latches down the button wheel. The button wheel can then be popped out from the front.

    The PCB assembly slides out from the right hand side.

    It uses the same PCB design as before.  The LiPo pack is about half the size ~50mAHr.  The overall build quality is slightly better.   

    Some of the cheaper PCB house only have silkscreen on the top layer which is on the back side of the PCB.  The LCD position no longer lines up with the silkscreen as it is shifted lower to accomodate the curvature of the case.

  • PCB High Res scans

    K.C. Lee01/28/2018 at 21:38 0 comments

    I made a couple of high resolution (2400DPI) scans of the bare PCB with my flatbed scanner.  I am going to be using the scans for the measurements. I'll have to wait for the second batch from the different supplier.  

    • The standoff keepout areas are marked with a Sharpie. They are in different location than the silkscreen.
    • Two of the pins covered by silk screen are not connected.  They are probably using I2C mode to access the MicroSD.  
    • One of the Mini-USB non-plated through holes encroaches into the "Next" button pad.  I'll resize the hole to try to minimize the effects and also might have to play around with the DRC to reduce the void.

    I imported the bitmap into Eagle CAD and overlay it on top on the layout template from github and there seems to be a lot of discrepancies on the placements.

    As I have learnt many times before, most of the freebies from someone else ended up costing me a lot.  I will be doing my own from scratch.

    This is what the layout should look like.  The scanned image has the right X/Y scaling and aligns with the placement holes.

    This is what I have done:

    • measure the PCB with a caliper
    • (previously done) rotate the scan to align with X/Y axis
    • reduce colour depth to 4. This make things goes faster while retaining details.
    • import into Eagle PCB as .BMP and 2400DPI
    • overlay measured board outline and main components

    I'll probably round the coordinates to inches or mm whichever one that gives a round number.  I am guessing the original layout was done in mm as it was designed in China.  I'll try to align the buttons on a grid.

  • First impressions

    K.C. Lee01/26/2018 at 21:45 2 comments

    One MP3 player arrived today.  The LCD doesn't have the ugly yellow/blue filter from the description.

    The plastic case is held together with 4 tabs near each of the corners and 2 on each end.  I broke all of 4 corners tabs when I pried it opened with a knife.  I think I'll have better luck with the 2nd batch from a different supplier as they are supposed to have screws and come with belt clip. 

    The PCB thickness is 0.026" (0.6mm).  The stereo connector (0.2") and the LCD (0.086") are the tallest components on each side of the PCB.

    The battery is a LiPo pack without any protection circuits nor a proper charger chips.  There is a silicon diode (CD1) in series from the VUSB as the charge circuit.  

    VUSB has a loose tolerance of 4.4V to 5.25V while a silicon diode drop is around 0.7V, so you might be charging the LiPO with up to 4.55V!  There are no current limiting other than the internal resistance of the USB cable, LiPO and power source. What can possibly go wrong?  (Cue Mission Impossible OP).

    The battery ( 0.831" x 0.860" x 0.113") is held above the Micro SD connector with a piece of double sided tape. I estimate the battery capacity to be around 100mAHr based on size.

    The LCD and the dome buttons are on the back side of the PCB.  The Red/Blue wires are the LCD backlight.  I measured 2.85V.  It is driven directly from pin 16 of the chip without a series resistor.

    The back side of the LCD diffuser is taped to the PCB with a piece of double sided tape.  There are two sets of footprints to accommodate modules with different cable lengths.

  • Multifunction I/O and buttons

    K.C. Lee12/18/2017 at 17:38 0 comments

    I thought about adding an analog MUX to select the signals as digital I/O pins do not like the intermediate voltages between '0' and '1'.  

    It turns out that there is a way of skipping the MUX in the STM32F10x family. There is an On/Off control that can be used to shutdown the "TTL Schmitt trigger" in the "Input Analog" mode (CNF[1:0]= "00", Mode[1:0]="00").  I have not yet confirmed if it is implemented in all of the GPIO pins or that it is specific to the ones with ADC.

    I have tied 3 pairs of GPIO together and connect them to the 3.5mm stereo connector giving access to GPIO, UART, Timer function, ADC and I2C.

    • Tip: PA10 (UART0 RXD/TIM1 CH3), PB0(ADC IN8/TIM3 CH3), PB6 (I2C SCI1)
    • Ring: PA9 (UART0 TXD/TIM1 CH2), PB1(ADC IN9/TIM3_CH4), PB7 (I2C SDA)

    I am hoping to implement diode clamps on the I/O for some protection.  The Ring/Tip pin assignments are consistent with FDTI 3.3V serial cable.

    Bootstrap key

     UART0 is used in the ROM bootstrap mode.  My intention is to hold down one of the keys (e.g. "Down") key during power on for entering the bootstrap mode.

    Battery backup

     I have hooked up the battery backup supply to the Li-ion battery directly.  This allows for 84 bytes of battery backed RAM as well as a Real Time Clock.

  • Initial PCB placement

    K.C. Lee12/16/2017 at 19:15 2 comments

    I took the PCB template from China cheap MP3 player hack, my STM32F103 breakout board and added a few parts. This is a preliminary placement.  I have not added the support circuit for the LCD or the random generator, but they should fit in the space.

    I can't do much until the MP3 players arrives in the new year.  I'll try to do my own measurement of the MP3 component placements on the PCB and confirm the footprints. I have no idea what the keep out areas and height restrictions are.  I like to get my PCB done right the first time.

    That could take a couple of weeks to a couple of months depending on the mood of the Canada Post and Canada Custom.  My recent packages seem to arrive very quickly.  May be the temp workers fired for the holiday season ignore Canada Post's rule to intentionally slow down packages from China.

  • Ordering parts

    K.C. Lee12/15/2017 at 15:45 0 comments

    I took the first step to order a couple of these.  I'll might have to wait quite a bit after the new year.  Just hope they forget about those pesky Li-ion batteries.

    There seems to be a slightly different version of these with a yellow/blue backlit LCD.  I order one too. 

    Ordered LTC4054 Li-ion charger from Aliexpress as I don't see it in China cheap MP3 player hack .  I could be wrong, but I can use it for some other projects.

View all 9 project logs

Enjoy this project?



Thomas wrote 01/27/2018 at 08:35 point

Really sweet. I'd like to have one, too.

One more use case: a CAN monitor (CAN shares USB pins and on-chip peripherals)

  Are you sure? yes | no

davedarko wrote 12/15/2017 at 18:09 point

I was about to point to a link but then saw it was the first in your reference :D Looking forward to see how this turns out, the other one was quite good :)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates