Enabling two additional serial ports on pcDuino

After some struggling I have been successful in enabling two additional serial ports on my pcDuino. The breakthrough came from JBV’s blog who attempted to enable the additional ports.

In order to do this, here is the high-level approach to take:

  1. Install 64 bit Ubuntu (I used 12.04 LTS and installed it in a VM on VirtualBox).
  2. Install cross-compiler for ARM on my 64 bit Ubuntu running on a 64 bit x86 system. DO NOT use the 32 bit Ubuntu because there are tools in the make process that require 64 bit OS. You will have to modify the make file to remove those tools if you use 32 bit.
  3. Build Linux kernel for pcDuino and verify that the new kernel runs on your pcDuino
  4. Modify a specific configuration file slightly and rebuild the kernel and deploy to the pcDuino again
  5. Verify that you can access the two new serial ports

Note – when you enable the serial ports, the SPI0 interface on the pins is no longer available, but I assume this is ok, as there is a SPI2 available.

Here are the steps in detail:

  1. You should have a running pcDuino. If not, you need to install an OS onto an SD card or onto the NAND depending on which version of pcDuino you are using. The SD Card association has a formatter. Then you can use Win32DiskImager.exe to put the image on the device. For the pcDuino Lite I use pcduino-lite_ubuntu_20130929.img as my image. Once installed, make sure you can boot – then configure everything in the first setup screen (i.e. expand file system, etc. as mentioned in my parent article). I recommend installing the new kernel on a brand new install of your OS if possible (different SD card) so that you don’t accidentally break a working SD card OS. Also, if you are running any significant applications, I strongly recommend setting up a swap file, 512MB should be fine.
  2. Ensure you have 64 bit Ubuntu installed, i.e. 12.04 LTS is a good choice. Ensure that the system is up-to-date with regard to updates. Optionally install it as a VM on VirtualBox or other Virtualization system like Citrix, VmWare, Hyper-V. You will need 1GB of RAM allocated and about 20 GB of disk space. One CPU is fine. Note that with VirtualBox you must select the Ubuntu 64 bit option, not the regular Ubuntu option in the drop-down. Other Linux flavors may also work.
  3. You are now logged in Ubuntu with a terminal window open. Follow instructions here to install cross-compiler and build the tar file that you will copy to the pcDuino.
  4. On that page you will need to get the cross compiler from here. The page appears to have a bunch of cross-compilers that look correct, but there is only one that is correct and that is like they say “arm hf crosscompiler for Linux”. Supposedly you could do this instead, but I don’t recommend it: sudo apt-get install gcc-arm-linux-gnueabihf dpkg-dev
  5. The build process can take about an hour.
  6. During make, you may get errors. One thing you may need to do is run sudo apt-get install libusb-1.0-0-dev
  7. You should have a couple of files in the kernel/output folder when it is done. You need to get the files onto the pcDuino. I recommend copying the files onto a thumb drive or use an FTP server if that is possible (or some other file sharing means available through services on the Internet). Follow the instructions to install, with the last step a reboot. Everything should come up normally after the reboot, including the pcDuino lubuntu user interface.
  8. Now you will be adding UART 5 and 6. To do this, follow the instructions here. One thing missing from his instructions is that at the point you are editing the fex file, you also need to disable [spi0_para], meaning under that section, set spi_used = 0
  9. Before you run make, you must first do a make mkproper in folder kernel/linux-sunxi and then move up to the kernel folder and do a make.
  10. Two brand-new files will appear in the output folder. Copy the tar file and install appropriately.
  11. After reboot your two serial ports should be available. This can be verified via running sudo dmesg | grep uart
  12. Finally, you need to test your code. You can use the sample code on JBV’s blog or go to Sparkfun’s C code page on serial interfacing. All their samples can be found here which you can copy via a git clone operation onto the pcDuino within its terminal window. Then you also need to somehow connect the serial output somewhere where it can be monitored. I like to use a serial-to-USB card like this one from Sparkfun. If you use that one you have to break a trace and solder a jumper to switch it from 5v to 3.3v mode. Sparkfun also sells a 3.3v board where you don’t need to do anything. I like the first option as I can reuse it for other 5v projects in the future.
  13. Wire it up and connect it to your PC’s USB. Then open a program like TeraTerm (Windows) or minicom (Linux) and set the baud rate to match that of the program you compiled – if you have RX-TX connected properly, when you run the program on the pcDuino you should see text appear in your terminal program and vice versa, if you type in the terminal program, the characters should be output to the program running on the pcDuino.

Why all the fuss to get this working? I’m working on a project related to OpenCPN and don’t want to add another board like a netduino or Mega with multiple serial ports.

Back to my pcDuino page.

5 thoughts on “Enabling two additional serial ports on pcDuino

  1. Thks for your article. I have updated my article to specify spi0 deactivation in fex files. There is an huge learning curve to have everything working , and I focused on kernel configuration. It’s good to have also the how ti for OS installation.

  2. Pingback: Enabling two additional serial ports on pcDuino | LinkSprite Learn Center

    • There are two main board types, one is the Lite version (the one I have) and the dev version with built in NAND for the kernel. If you using the dev version, you need to follow different instructions than the Lite in step 4 of the link I have in step 3 above (step 4 on this page: http://www.pcduino.com/?p=957).

      If you are using the Lite like me, let me know and I’ll see if I can think of something else.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>