The mBot is a great little programmable robot, and my 9 year-old nephew is really getting into it. His computer can only use Mac OS 10.7.5 Lion, and the mBlock software almost works. Here’s how I got it running perfectly.
Download MacPostFactor (formerly MLPostFactor) - An easy to use installer application that enables you to effortlessly deploy the Mountain LionMountain Lion, Mavericks or Yosemite operating system.
Posts about MacPostFactor written by MacManus.nl. MacPostFactor v2.0.1 is no longer supported. A new version is in development and will be released in 2020. OS X Mav+ kernels are now stored online (reduces MacPostFactor's size and allows MLforAll to add a new kernel without updating the MacPostFactor app.
Macpostfactor 2.0.1
tl;wr:
- Install sketchy driver ver.1.2 for CH340G from a Russian website. (direct link)
- Open
mBlock_v3.4.8.app/Contents/Resources/Arduino/Arduino.app/Contents/Java/hardware/arduino/avr/platform.txt
- Find line
tools.avrdude.upload.pattern='{cmd.path}' '-C{config.path}' {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D '-Uflash:w:{build.path}/{build.project_name}.hex:i'
- Wrap the -P in double quotes:
tools.avrdude.upload.pattern='{cmd.path}' '-C{config.path}' {upload.verbose} -p{build.mcu} -c{upload.protocol} '-P{serial.port}' -b{upload.speed} -D '-Uflash:w:{build.path}/{build.project_name}.hex:i'
- Comment on my GitHub PR which fixes this issue.
mBot
I was lucky to pick up an mBot from my local Radio Shack at a discount before it closed. My nephew has been getting more interested in computers, robots, and programming, and I figured it would be a great gift. It uses an app called mBlock, which is based on Scratch 2.0. It has a host of interesting components: ultrasonic, line follower, IR receiver (with remote), IR transmitter, light, buttons, beeper, bluetooth, and USB/serial. It has expandable ports with RJ25 connectors. Each port provides power, i2c, and two GPIO or analog pins. This makes custom add-ons relatively easy; certainly much easier than Dash & Dot from Wonder Workshop!
Old computer problems
The website for mBlock simply says “latest OSX recommended.” The only computer my nephew has unfettered access to runs MacOS 10.7 Lion, which was released in 2011. I was happy to find that mBlock launched fine and appeared to work. I only ran into problems once I wanted it to connect to the mBot over USB.
Programming the mBot requires you install an ‘Arduino Driver’. Unfortunately even after installing the driver, the mBot is not recognized. The mBot and some other budget Arduino-ish devices use very cheap CH340/CH341 USB->Serial converters instead of the higher-quality FTDI chips. It turns out the driver included with mBlock.app only works on MacOS X 10.9 and above.
Rather than trying to get MacPostFactor running on his computer (a MacBook 4,1), I was determined to find a driver for this chip that would work on older hardware. USB->Serial converters have been around for ages, there has to be a compatible driver out there, right?
Fortunately there is; however, it does feel sketchy. There is a Russian hobbyist electronics website that has a page devoted to the CH340G, and includes an older version of the same driver, 1.2. This one installs fine on MacOS 10.7. Disclaimer: I’m not responsible for this driver messing up your computer. I wish that was enough to get everything working, but unfortunately it isn’t so simple.
New serial problems
As you see above, the driver doesn’t work for the most frustrating reasons. The .kext creates serial devices at paths like /dev/tty.wch ch341 USB=>RS232 1d10
, and the mBlock toolchain doesn’t escape the special characters. This results in avrdude ignoring the entire device path after the first space. It tries to upload to an arduino at /dev/tty.wch
and fails, with a file not found error.
Failed ideas
First, I made a symbolic link at /dev/tty.mbot
that points to /dev/tty.wch ch341 USB=>RS232 1d10
. The command doesn’t survive restarts, so I created a LaunchDaemon and shell script. They have to run at startup as root, which is annoying, and means you have to secure them properly. Also, sometimes the mBot gets created with a slightly different name (ends with 1a20
instead of 1d10
), which breaks everything until you reinsert the cable and pray it works. I don’t want a 9 year-old to deal with that.
Second, I assumed this must be a problem with mBlock’s code. I went through the (laborious, 2) process of getting mBlock 3.4.5 to compile on my Mac. I changed the relevant UploaderEx.as code to wrap the device’s name in double quotes. I recompiled and updated the .app package, but it still failed. avrdude seemed to be interpreting the double quotes as parts of the path. By the way, if you want to compile mBlock 3.x for Mac and you stumble on this post, you have to use AIR SDK + Compilers 19.0. You’re welcome.
Finally, I tested this behavior on the latest vanilla Arduino app and my personal computer, and found that this is a bug in Arduino. It turns out this has even been discussed before. The post there helped me find the right Arduino txt file to fix the problem.
Super serial solutions
mBlock.app includes a full copy of Arduino.app, version 1.6.5-r5. You can modify the file at mBlock_v3.4.8.app/Contents/Resources/Arduino/Arduino.app/Contents/Java/hardware/arduino/avr/platform.txt
to wrap the upload.pattern
’s -P{serial.port}
option in double quotes: '-P{serial.port}'
. This causes the path to be passed successfully down the entire toolchain.
Finally
I can relax knowing that when I’m back in New York, my nephew and his father can use his fancy new robot reliably and with ease. Now he can focus on making amazing programs, educational failures, and mischief.
I’d like Arduino to make this change in their code. I’ve submitted a pull request, but given the previous comments, it won’t get approved without enough support.
-vkm
Who’s Varun?
I most recently was the founder of an HR tech startup, Disqovery. I have worn many hats, and I like making things. I also like talking business. You can reach me at smartperson@gmail.com, @smartperson, Github, and LinkedIn.
MacPostfactor is a tool to install Mac OSX 10.8+ on older Macbooks that normally only support up to OSX 10.7 (Lion). It works through a combination of a highly customized installer, a replaced set of drivers and various frameworks, and the original installation app from the App Store. The installation can be done directly on a Macbook already running OSX Lion (so no USB disk required), or on an USB media for installation on another system.
- You need an Intel-based Macbook capable of running OSX Lion (10.7) (otherwise your Mac is too old), but one that does not support OSX Mountain Lion (10.8) or higher. PowerPC-based Macs are not supported (they do not run OSX Lion).
- The installer app of the OSX version to install, from the App Store.
No particular or in-depth knowledge of Mac or OSX is required to use this. The installation can be done directly on a working Mac that's running OSX Lion (10.7).
- Warning
- Do not use MacPostFactor to install OSX on a system that officially supports newer OSX versions. Doing so will most likely make your system unbootable.
→ Official download link (from Mediafire).
Using MacPostFactor is very straight forward:
- Retrieve the original installer app from the App Store. You may need to use another Mac that supports the version of OS X you want to install in order to be able to download the app directly from the App Store. See below for more tips on how to get the install app.Place the install app in the Applications. Otherwise MacPostFactor won't find it.
- Dowload the installer, open the DMG and drag MacPostfactor in the Applications as well.
- Start MacPostFactor and follow the on-screen instructions. The application will automatically determine which versions of OS X can be installed on your hardware. Choose the version of OSX you wish to install, and the disk/volume to install to. If you select to install to an external drive, the installer will create a bootable installation media, allowing you to perform an installation on another system. Selecting the volume on an internal drive will perform a clean install on that volume. You can select the currently active volume, which will then replace OSX Lion with whatever OSX version you choose.Keep in mind that 10.9 Mavericks and 10.10 Yosemite don't work properly on systems with an Intel GMA950 or X3100 graphics card, as there are no 64-bit drivers for those cards, and they do not properly support the newer OpenGL and OpenCL frameworks.
- The installer will perform some tests, verifying your Mac is capable of running the selected OSX version. When that's done, the installation will continue. It will take some time for this to complete.
- When the installation has succesfully completed, you will be prompted to reboot. In case of an install to a local disk, you can restart the system to boot into the new system. You will then go through the first run wizard, like on a normal Mac.If you've done the installation to an external USB media, you can remove the media and use that to install the modified OSX version on another system.
Alternate ways of getting the install app
The only tricky part is to actually get the install app from the App Store of the OSX version you want to install. The App Store does not allow you to download the app on a Macbook that does not support it, so you'll have to be a bit creative.
Macpostfactor No Installer App Found
You could use a Mac that supports the newer OSX versions and directly download the app from the App Store that way. It is not a problem if the OSX on that Mac is newer than the version you want to download. You'll get a warning but the download will continue. Once downloaded, you can then copy the app from the /Applications folder to another system, through network or USB.
Macpostfactor Skip Ad Problem
If you use an USB media, it's best to 'compress' the app before copying to ensure all files remain in place: right-click the app, then click Compress. This will create a ZIP file in the current folder.
Note that VMWare Fusion or Parallels supports newer OSX versions. Installing OSX as a virtual machine will also allow you to download the installer app from within that VM.