From Chip to linux — MyIMX233

Building a linux capable circuit board at home from designing to soldering to installing Arch Linux — Its not hard! Its costs less than 2000 Rs. (~$28). Sounds fun!

samarjit.samanta

--

Why it is not hard?
I am a professional software developer. But this skill was not used.
I have done bachelors in electronics. But they never taught any of these in school.
Skills you will need — good eyes, steady hand in soldering, some youtube videos, some links to contents, and patience patience patience. If you have arduino/raspberry skills it will help a little.

Overview of how it works

We need a microprocessor. Microprocessors have tiny RAM and tiny persistent memory. So we need to wire both bigger RAM and bigger persistent memory to hold OS image data. which in our case will be SD card big enough to hold linux. 2GB SD card is enough. Microprocessor comes with small pre-built programs which is present in its ROM and comes factory programmed. These small programs loads first thing and runs on power-up. These can be configured to look for next bigger of programs to load and run either from SD card or from NAND flash memory. They look for specific memory address in SD card or NAND flash and starts loading and executing from there. These first program that gets loaded from SD card or NAND flash memory are the bootlets or bootloaders (u-boot). These are slightly bigger programs and does some basic health checks and then loads OS image. OS binary images are also hardware aware. Meaning during building the OS image a board support package (BSP) was specified. I believe these become the hardware abstraction layer (HAL). On top of it sits the linux kernel. You can build your own OS image using linux BSP+linux kernel and building them all together using YOCTO. This blog explain more about it.

We connect the PCB to laptop using a micro usb which provides power. We talk to microprocessor during booting process using RS232 interface. So using RS232 COM interface we can see all the console logs and even you can send commands to PCB using RS232.

Design Concerns

  • Microprocessor to RAM connection requires high speed PCB design and it is most critical. I believe 400MHz connectivity or is it 400mbps. I kind of forgot now.
  • Microprocessor to SD card connectivity is also high speed. Approx 96MHz.
  • Microprocessor to USB data connection is also high speed.
  • microprocessor to RS232 lower speed but you can still follow same quality.
  • power supply — microprocessors are a bit picky about power supply and interference/harmonics/oscillations in power supply cause lot of instability. You will need lots of bypass caps to suppress harmonics and stabilize power supply.

Tools I used:

  • Small fine tip soldering iron 12v. MAX PAMMA 550 (500Rs)— It was cheapest and not very good. But I soldered 0.5mm thin pads with it.
  • Multimeter — DM97 again nothing special but real cheap ones send out a lot of current in the leads. So better to go for a decent ones.
  • Antistatic Tweezers — not absolutely necessary
  • Thin soldering wire, flux, wick etc. Since my soldering iron was weak thin soldering iron worked. Good thing it came with a roll.
  • TTL to USB converter — PL2303 This is also a bit painful with their drivers. Better to use an FTDI.

Knowledge

Now this part is important, and good news is knowledge can be acquired. I am also new to it, but I will cover it sufficiently. PCB design is very important.

High speed circuit design upto 400 MHz interface

Length matching with curvy lines

The processor to RAM connections are high speed bus. Imagine if one signal travels longer and another one travels through shorter path they will both reach the destination at different time. Now the RAM will latch onto the input data at rising edge or falling edge of the clock pulse. If one of the signals travel slower then it may not reach during the instant when data is read by ram. This is the reason all these data lines should have same length. Now the challenge is everything cannot have same length because you have limited real estate. So subdivide into batches, and length tune each batch within a certain tolerance. Our RAM address bus is one batch, data lower byte D0-D7 is another batch, data higher byte D8-D14 is another batch. You can find other batch of connections like control signals can be one batch. If you have more RAM there will be more batches. Sometimes you can find this info in the datasheet of the microprocessor. To have a reliable clock pulse, it is a differential line. Differential pairs should have equal spacing between them from start to end. In general clock trace length should be average length of all data lines. Since we are using two layer board, if there are traces on top and bottom layer make sure they cross each other perpendicular. But try not to have traces in both layers. Having ground plane and traces on the other side makes it most stable. Kicad comes with differential pair routing capability. Kicad also comes with length matching utility. Without these two features designing the PCB would have been impossible. There is another aspect called impedance matching which I did not use.

Power supply stabilization filtering out harmonics

In general place bypass capacitors as close as possible physically to the pins of microprocessor to filter unwanted frequencies. The lower caps are usually smaller in size and can be placed closest to the microprocessor pins. The larger ones can be pushed away. One advantage of this imx233 microprocessor is that, it contains the power management unit inside the micro. A microprocessor splits power into multiple voltage levels each used for different purposes and each are having maximum power rating beyoned which if we draw it’s voltage might go down. Placing simple resistors to reduce voltage might be easy but resistances tend to eat up a lot of energy and consume as heat. So mostly switching mode voltage regulators are used. Inside this micro voltage is reduced in steps. Knowing each step will help in debugging if voltages are not matching up to the specs on power up. Also note that not all the powers are immediately available until some boot sequence is executed. I have noted down the specific lengths have below.

Soldering

Soldering is not too hard. I specified 5mil trace and 5mil spacing in RAM bus and other traces emanating from microprocessor. Microprocessor pins itself are very thin so there was not much choice. I got my PCBs manufactured in PCBPOWER. Their quality was very good. One major advantage was that, they were able to put soldermask between 5mil pads of the microprocessor. That really helps to avoid pin short circuiting between pads. One more advantage was to have the pads silvered HAL. This also helps in soldering. I would just add flux, the already silvered pads have enough solder to solder microprocessor pads to the pcb.

Circuit diagram

https://github.com/samarjit/MyIMX233/blob/master/plot_sch/MyIMX233_3.pdf

Components Guide Tip

I ordered most stuff from http://www.shelfkey.com/. They have various sources and prices are reasonable. If you pick up from their store then you will not even incur the local postal charges of 200 Rs.

MicroSD connector — This one came costly with the kicad footprint which I already had. In local market there is a cheaper one available but you will need to download the footprint from somewhere. My latest circuit has it.

Microusb — For this the cheaper ones are somehow bad, either they are very difficult to secure to the board, or the pins are notoriously difficult to solder. You would want to solder it very well so that it does not break or lift traces, because everyday you will tug at it while trying to plug in/out your microusb cable. Other option is to use a type A/type B usb with through hole ones. Sturdiest connection! You wouldn’t want your board to be unusable just because of poor usb trace broken.

My Github README

This part is a readme from my github account verbatim.

I am starting to build a single board computer with freescale microprocessor iMX233 128 LQFP and 64MB DDR2 SDRAM in 66TSOP. This single board computer will be bare bones with lots of GPIO exposed. There is no special goal for this project. I am just curious to see if it works. In future I might add an LCD. The PCB is two layered only and can be manufactured cheap.

Github: https://github.com/samarjit/MyIMX233

TODOs (done)

  • Increase pad lengths of LQFP footprint. (done. Hope to mitigate the soldermask between pads issue |<-0.06mm space-><-0.08mm web-><-0.06mm space->| = 0.2mm)
  • Perhaps add a jumper on the 2.5v LineReg and separate out VDD_MEM to be able to test the 2.5v is not 0 due to loading. (skipped)
  • 88 USB_ID SSP1_DETECT ? Should I use this to CD of SD card connector or micro USB ID pin? In my circuit it is pulled low via LED. Tux,calculator does the same too.
  • Add option to boot resistors LCD_RS and LCD_00..LCD_05 (done)
  • 14 LCD_RS ? High for register boot mode. Or low with 47k resistor for OTP boot mode. Olimex is confusing OTP is set MMBR and LCD_RS is high. (done)
  • Schottkey Diode D1 VDD4P2 direction. Its strange in ref diagram vs 5v wall. VDD4P2 -|>||- VDDBATT. (done Optional. Not populated in running board)
  • Series resistor 1E for preventing oscillations (done 3 series resistor added, usb, batt, 4p2) /in old circuit Test by removing Diode, and LED_RS to gnd via resistor.
  • RESET circuit? Make sure not to get into USB recovery mode. add zener 1.0v so that it never reached 3.3v or just remove reset circuit altogether.
  • Configure to get rid of batteries as per rev-c circuit. Add 1k resistors in DCDC_BATT and BATT and some caps to GND.
  • Need to convert the SD card connector to a cheaper version available on ebay or alibaba. (done part-ATTEND 112J-TDAR-R01) I got the files from https://forum.kicad.info/t/microsd-component-footprint-help/3095/5 and placed in parts/ folder. It would be awesome if I can find some 3D model of it. If someone finds it please create an issue. (Yes found)
  • Make DDR RAM pin pads longer (new)
  • Make alternate USB plug preferably through hole or longer pads in micro USB. (new)
  • Make micro-SD pads larger and longer and add a few decoupling capacitors.(new)
  • Make more rooms for the inductor as most inductors are really big 8mm long plus place for hand soldering.(new)

TODOs (ignored)

  • POWER off circuit?
  • Is Micro SD pullups on all pins necessary? SSP1_DETECT used? (done added them in the bottom side. Data3/CS pulled low)
  • Added 120R between CLK nCLK.

Length Tuning

  • D0..D7 LDQS LDM — 39.7mm tuning (real 40.2mm)
  • CLK nCLK — real 32.2/32.6mm
  • D8..D15 UDQS UDM — 25.5mm tuning (real 26.0mm)
  • Address: 32.35mm ~ 25mm
  • CKE- 20.2mm
  • SD: 24.8mm tuning (real 25.3mm)

Installation steps

Cloning this repository should work. It does use opendous conn_fci from https://github.com/cpavlina/kicad-pcblib.git, https://github.com/cpavlina/kicad-schlib.git Copy kicad-pcblib\conn-fci.pretty to KiCad\share\kicad\modules\conn-fci.pretty Add kicad-schlib-master\library\conn-fci.lib to SchematicEditor -> ComponentLibraries Add opendous to component libraries too.

Drivers for this project.

  • Until recently I didn’t know of a decent opensource software for PCB designing or circuit designing which can be used to design complicated circuits involving microprocessor. I recently discovered KiCAD which is opensource pcb designing software and people have done microprocessor design with it eg. OLinuXino. I am trying to learn PCB designing using KiCAD now.
  • Second driver was Clementine Core project which I saw in circuitmaker website. This schematic looked so simple and pcb was on 2 layer design, which changed my thought process altogether that linux running board designs may be something I can try.
  • Third driver was LibreCalc which almost proved that KiCAD can be used to design IMX233 based board. I hope to learn from their mistakes, but a newbee like me can uncover a whole lot of new mystries.

So I have put together a mashup of schematic design of IMX233 and 64MB RAM from freescale reference design and other sources.
Freescale microprocessor:
DDR RAM — I think all these below RAM chips are compatible.

  • AS4C32M16MD1–5TCN
  • HY5DU121622D(L)T(P)-J
  • MT46V32M16P-5B:J (This is the only one I can source, so I am using this)

This project is a work in progress and there is no gurantee that I will ever be able to complete it :). But if you want to try building same stuff as I am building. Go ahead and fork it. Download KiCad. I am using nightly version of it, because it does not require you to export the netlist and import it again in pcb editor. Make the workflow really easy. I can see one bug in KiCAD, which is after modifying the footprint by adding a step file. It looses the saved settings.

Once you have installed KiCAD, open MyIMX233.pro file.

MyIMX233.sch — Schematic file.
MyIMX233.kicad_pcb — PCB
ReferenceSch — contains reference materials. I uploaded all of them for providing content incase someone wants to understand the design.

Progress:

Oct 8 It worked! You can start building one today for yourself :)

Few soldering quirks are there. USB pads are quite small to solder. Also pad to hold USB in place is also very small and bad for soldering. Even the SD card pads are also small for soldering. These were new footprints so in next version I will make longer pads for these. RAM pads can be made slightly longer for reliable soldering. Soldered board and powered up without SD card. Some error were coming 0x80207002. Boot loader looking for I2C and it is not initialized. Turned out to be soldering of one pin was not proper for LQFP128. Fixed this pin issue then SD card missing related errors were coming. Added SD card with bogus data 0x8020A007 — ERROR_DDI_SD_CONFIG_BLOCK_NOT_FOUND. Added SD card formatted properly but still 0x8020A007. Little bit further digging showed that SD card MBR boot is not enabled by default. We need to burn an OPT bit HW_OCOTP_ROM0::SD_MBR_BOOT to enable booting from SD card. This process is irreversible. Default boot mode is BCB. I read up again librecalc’s failure blog. It gave two perl programs to burn the SD card with u-boot in BCB mode. The 2nd perl program didn’t run as it assumed smaller SD cards only. I edited the perl program to make it find proper boot signatures. Now we can see something HTLC in UART console. That’s too less info to debug further. At this point I posted in freescale community. https://community.nxp.com/message/949934. I decided to blow the MBR OTP flag using BitBurner. Then added MBR based uSD card and same u-boot. Now again it shows HTLC. Good news is that MBR booting works. But it fails very soon. Need bootlets which gives more detailed log instead of u-boot. Turned out voltages are fluctuating all 3v3, 4v2, 1v8, 1v. They were fluctuating in a cycle. I burned official Olinuxino image in SD card. That seems to have bootlets so it gave more info. After right after memory FRAC 0x92926192 it reboots. I heated up all the pins of DDR and iMX233 with soldering iron. It goes 1 more line ahead in log init_ddr_mt46v32m16_133Mhz and sometimes power 0x00820710. I added a big capacitor in place of battery which goes the log to further and says uSD card general error ending with r14<0>HTLLLL... I tried adding a few caps on 3v3. But nothing helped. Then I tried the other jumper of battery mode. Then it started loading kernel.

Aug 2017

Started modifying the schematic to make battery and USB wall power optional using jumpers. Also realized boot selection can be done using resistors. Sent for fabrication of PCB to pcbpower.

July 2017 end first soldered board

Good news is most of the components fitted. Also I got some confidence about my KiCAD skills. Some shortcomings were observed, like the pads for soldering were two short for the fine pitched LQFP128 0.4mm pitch and solder mask dams were not created between pads which made it incredibly hard to solder. I will have to customize the LQFP128 footprint to make it suitable for hand soldering. Some 0402 caps were placed very close, I realized the courtyard verification of components is not turned on by default. I had limited success like UART was working USB was working, BitBurner was working and showing all the OPT(One Time Programmable) bits. Some gibberish was coming on UART console. I used solder paste for soldering, so I thought some shorting might be happening. Then I tried to do reflow soldering to make the solder joints liquify once and then quickly cool it using a frying pan. It actually fried my board! I also mistakenly soldered uSD card with power on! Carelessness!

  • I also ordered components. I didn’t realize this would be a pain. element14 is not that accessible for an individual. I ordered mostly from Shelfkey and some from KitsNSpares. I am still tensed if footprints I chose will match the actual components. Second I am very much tensed about soldering 0402 components.
  • Final version of PCB sent for fab in pcbpower.
  • Added few options to use DCDC. I was not comfortable of grounding DCDC_BATT and BATT pins, so I added a few jumpers. Also added provisions to add battery.
  • Learnt basic Freecad to build the Step files of DDR SDRAM 66TSOP. Here is the project I created — MT46V32M16P-5B-Freecad-Step.
  • Initial version. DDR RAM child 3D missing and SD card’s 3D missing.
  • Wiggly trace lines, learnt Length Matching in Kicad.
  • Figured out placement of components. I am going with Clementine Core’s placement which seems very good.
  • Initial version with the very basics layed out.

Originally published at mylinuxsbc.blogspot.com.

--

--

samarjit.samanta

Developer in UI, reactjs, angularjs, backend nodejs, java, springboot. Tinkerer of electronics. Loves to do everything hands on.