No announcement yet.

2006 Mazda 3 + Gentoo Linux and custom software

  • Filter
  • Time
  • Show
Clear All
new posts

  • 2006 Mazda 3 + Gentoo Linux and custom software

    I've been thinking about doing something with a car PC for a while. When my two year old son (allegedly) broke the screen on my wife's netbook, I had a good starting point.

    Main goals of this project:
    • DAB+ radio to improve reception issues and receive more stations
    • MP3 playback with storage beyond the capabilities of the factory CD player
    • Steering wheel controls
    • Navigation on a reasonably sized screen
    • Sensor display and logging

    And I want to do all of the above using software I wrote myself (except navigation - that's too hard).

    I've spent a couple of months planning, writing software, ordering components, etc. It is taking ages because the two year old doesn't leave me with a huge amount of spare time. Now I've finally started putting it all together. I'm starting with the radio, because I don't like driving without music.

    DAB+ Radio

    Components for this phase:
    • Lenovo S10e netbook (broken screen - original cost A$299).
    • Ultimate DAB/FM Radio with Motorola antenna adapter (US$134.90 delivered from craigbrass)
    • Car PC JoyCon Exr (steering wheel control USB adapter) (US$45 + $5 postage on ebay)
    • Arlec junction box ($4.90 from Bunnings)
    • Aerpro wiring harness ($17.56 from Supercheap Auto)

    The radio took a long time to arrive, but after that it didn't take too long to write some software for it. The info on the craigbrass forums was helpful. I have a simple touchscreen interface for changing stations and displaying information, plus I can also use steering wheel controls for changing station and volume.


    I put the radio module into a little junction box I got from Bunnings and drilled some holes in the side (not very well) for the connections.

    I removed the factory stereo and glovebox. Then with some help from various websites confirmed what all the connections were on the main connector to the stereo.

    Finally a super-dodgy initial installation of the radio for testing purposes. Note it is wired directly to the speakers (no amp). This works reasonably as a proof of concept and confirms that I get excellent reception and it is fine for the short term while I get other things installed and working.

    Just after doing this I found a wiring harness at Supercheap Auto (one of only three places in Perth that stock it according to the manufacturer's website) which I prefer to waiting weeks to get one slightly cheaper from the US. So I'll be tidying up the wiring very soon.


    Next up, I wanted to experiment with the LCD while I had it out of the car. It was much harder to find the information about this connector but I found it eventually on one of the Mazda forums. I hooked it up to a 12v bench power supply and connected to the data lines with a Microchip CAN Bus Demo Board (US$55 + $17.21 postage for two, Microchip Direct). After a couple of nights I have learned everything I need to know about the protocol.

    This is on the low speed (125kbit) CAN bus (note some information was found on Displaying text requires three consecutive messages.

    Message ID 0x28f (8 bytes)
    Byte 0: Turns on CD-IN, MD-IN, ST, Dolby, AF, RPT, and RDM.
    Byte 1: Turns on AUTO-M, TP, TA and PTY.
    Byte 3: Enables intermediate characters between letters: . : ' "
    Byte 4: Used for setting the clock. Send 0x90 twice then 0x80 to start setting. Then 0x90 followed by 0x80 to go to the next field. 0x88 changes the current select (250ms repeat rate).

    Message ID 0x290 (8 bytes)
    Byte 0: Nothing displayed when 0x00. Set to 0xc0 to display full message. 0xd0 or 0xe0 or 0xf0 to display ony the second half (this doesn't seem useful).
    Bytes 1-7: Characters to display. ASCII codes from 0x20 to 0x7e (except 0x5c is replaced with the yen sign). 0xdf degrees sign, 0xf0 right arrow, 0xf1 left arrow, 0xf2 backslash, 0xf3 small C, 0xf4 small H, 0xf5 small D. The remaining characters are Japanese.

    Message ID 0x291 (8 bytes)
    Byte 0: Set to 0x85. Other values possibly used for scrolling?
    Bytes 1-2: Repeat of bytes 6 and 7 from 0x290 message.
    Bytes 3-7: Remaining 5 characters to display.

    Once installed back in the car, the LCD will be a handy secondary display and clock. The clock section can also be configured to display fuel consumption etc, but I couldn't work out how (my car doesn't support this functionality) and can't really be bothered. I think I would rather have a clock, and use the touchscreen for more advanced display options.

    I tried various messages to get the section on the right to display something but no luck. This section is meant for climate control and ambient temperature display (which my car doesn't have). I think the only way I'll get this to work is if someone else with the same LCD can collect some messages off the CAN bus for me to look at. Currently it is blank.

    Next planned work:
    • Modify wiring harness to have pins for CAN bus and steering wheel controls
    • Install steering wheel control USB adapter
    • Wire radio and sound from laptop in properly, buy amplifier if necessary (probably will be)
    • Install CAN bus adapters
    • Power!
    • Touchscreen installation

    (Sounds simple but this will probably take weeks or maybe months).

  • #2
    Greetings from good old, Victoria, other end of Town

    I like what you're doing here, esepcially wrt the CAN-bus. Sometimes I wish our beloved old Falcons had the same fundtionality for our ICC's, running on a seperate LS Can-bus. Instead all that fundtionality is hard-coded into the cd-stacker/radio eprom, and only the HVAC runs via HS Can.

    But, good work, I think the end-result is going to be exciting!

    Kind regards,
    F6 Tornado Project Log ; HP Blackbird Watercooled Server

    Beta Tester for Centrafuse and 3dConnexion (No business affiliation with either)


    • #3
      Hi Steve, looks like a really good job so far. Looking forward to how it turns out, esp in regards to your antenna for the DAB+. Not sure what the mazda has but I've had some success with the standard aluminum job on my Commodore. I think the secret was that being a como it was a pretty simple affair without signal amps etc.

      Hope it turns out well! Tom.
      Deathstar Worklog


      • #4
        Nice stuff Steve, looking forward to seeing further progress
        Corolla WorkLog


        • #5
          Wiring Harness

          The wiring harness I bought from Supercheap Auto is designed for replacing the factory head unit, and consequently is missing the all important CAN bus and steering wheel control connectors. To fix this:
          • I've repositioned two unnecessary pins to use for the CAN bus.
          • I've made two additional pins out of paper clips for the steering wheel controls.

          Making additional pins

          Completed wiring harness

          Steering Wheel Controls

          The CarPC Joycon Exr is a very nice product that converts resistive steering wheel controls into a USB keyboard. A Windows application is required to teach it what all the buttons are. I found it was necessary to adjust the sensitivity by adjusting one of the trimpots so it could recognise the difference between volume up and volume down, but after that it was trivial to teach it the key mapping.

          So now I have the wiring harness installed and the steering wheel controls hooked up to the car and working. The wiring is actually better than it was before, though it looks even messier. The Joycon Exr is in the blue heat shrink stuff, but I haven't shrunk it down this evening because that would be noisy and the boy is sleeping.

          Powered USB Hub

          I bought a $19 powered USB hub from Storm Computers. It has seven ports, and takes power from both USB and a 5 volt/1 amp DC connection. On the box it said it had "8 fantastic LED lights". I didn't realise they would be on all the time, with the big one in the middle flashing several different colours. The inefficiency of this arrangement offends me, so I have desoldered seven of them.

          USB hub prior to desoldering work

          CAN Adapters

          I'm now unsure whether there is anywhere convenient to connect to the high speed CAN bus. Obviously there is a port on the OBD-II connector, but that is a fair distance away and would be difficult to wire neatly without exposed wiring. I started putting one CAN adapter in another of those white boxes I got from Bunnings, but it's incomplete because I need to use a drill and the boy is asleep.


          I will need an amplifier of some sort. Possibly the Helder MKII because it is small and doesn't use much power. I don't really need anything powerful because I'm only using the factory speakers.


          After convincing myself earlier in the week that I could just connect to the cigarette lighter power, I've now changed my mind and decided to do it properly.

          • Install CAN Bus adapter and USB hub
          • Start working on wiring up the audio properly.
          • Power!
          • Touchscreen installation


          • #6
            Top Work!


            • #7
              Tried to achieve something to tidy up the wiring tonight, but only proved to myself that I'm not very good at soldering.

              Wiring diagram

              I think I need to get some short USB cables so this doesn't get any crazier than it already is.


              • #8
                Progress this week
                • Tidied up wiring a lot
                • Ordered 10 50cm USB cables from Dealextreme for about $3.50.
                • Ordered an amp wiring kit ($17.40 + postage from
                • Received my GM-2 5Hz USB GPS
                • Got my software working with the GPS after having some trouble with an old version of gpsd - the API in the new version is quite different
                • Got the touchscreen working in Linux (which was quite easy), but the vertical axis is upside down

                Further progress required for touchscreen installation
                • Get GPS and radio to play nicely by getting a consistent assignment to ttyUSB0 and ttyUSB1 - I believe this requires working with udev.
                • Fix touchscreen vertical axis
                • Receive short USB cables
                • Install GPS and CAN bus adapter into car
                • Automated startup and shutdown scripts


                • #9
                  udev rules (mainly for my reference)

                  Command to get device info: udevadm info -a -p /class/tty/ttyUSB0

                  The information is presented as a hierarchy - for the rule to match the ttyUSB device rather than creating a useless symlink to a bus/usb/... thing, it is necessary to understand the difference between SUBSYSTEM and SUBSYSTEMS, ATTR and ATTRS, etc. Refer to Writing udev rules.

                  Rules that work:
                  SUBSYSTEMS=="usb", ATTRS{idProduct}=="ea60", ATTRS{idVendor}=="10c4", KERNEL=="ttyUSB*", SYMLINK="gps"
                  SUBSYSTEMS=="usb", ATTRS{idProduct}=="6001", ATTRS{idVendor}=="0403", KERNEL=="ttyUSB*", SYMLINK="radio"

                  This gives me /dev/gps and /dev/radio symlinks.


                  • #10
                    I have broken my touchscreen. After spending all evening trying to calibrate it, I concluded that it was stuck on upside down and needed to be flipped over. Bad idea.



                    • #11
                      What CAN bus adapter are you using?

                      Also, tell me more about what software is powering all this, reading from the can bus, etc.
                      Former author of LinuxICE, nghost, nobdy.
                      Current author of Automotive Message Broker (AMB).
                      Works on Tizen IVI. Does not represent anyone or anything but himself.


                      • #12
                        Sadface about the screen mate
                        Deathstar Worklog


                        • #13
                          Originally posted by tripzero View Post
                          What CAN bus adapter are you using?

                          Also, tell me more about what software is powering all this, reading from the can bus, etc.
                          CAN bus adapters are expensive, so I'm using the Microchip MCP2515DM-BM demo board ($55 for two, plus shipping). Effectively it is the same thing for a much lower price. I wrote all the software myself using libusb because nothing existed previously to support it under Linux.


                          • #14
                            Originally posted by soyfish View Post
                            Sadface about the screen mate
                            Very frustrating - there are some things that I shouldn't try to do when I'm getting tired.

                            I've ordered a replacement from DealExtreme for only $35 which sounds like it will use the same drivers and everything. Now just have to wait 3 weeks for it to arrive.


                            • #15
                              Originally posted by StevePER View Post
                              CAN bus adapters are expensive, so I'm using the Microchip MCP2515DM-BM demo board ($55 for two, plus shipping). Effectively it is the same thing for a much lower price. I wrote all the software myself using libusb because nothing existed previously to support it under Linux.
                              Have you thought about tying in your software with something like nobdy? This board would make a nice provider plugin.
                              Former author of LinuxICE, nghost, nobdy.
                              Current author of Automotive Message Broker (AMB).
                              Works on Tizen IVI. Does not represent anyone or anything but himself.