Encrypted USB Bootloader for AVRs

It probably doesn’t matter much for the hacker who sleeps with a bag of various microcontroller flash programmers under the pillow, but for an end-user to apply a firmware upgrade, convenience is king. These days that means using USB, and there are a few good AVR USB bootloaders out there.

But [Dmitry Grinberg] wanted more: the ability to encrypt the ROM images and verify that they haven’t been tampered with or otherwise messed up in transit. Combined with the USB requirement, that meant writing his own bootloader and PC-side tools. His bootloader will take unencrypted uploads if it doesn’t have a password, but if it’s compiled with a key, it will only accept (correctly) encrypted hex files.

Since the bootloader, including the USB firmware, is on the hefty side at 3.3 kB, [Dmitry] included hooks to re-use the bootloader’s USB code from within the target application. So if you were going to use V-USB in your program anyway, it doesn’t actually take up that much extra space. It’s a cute trick, but it ties the bootloader and user program together in a way that gives us the willies, without specifically knowing why. Perhaps we can debate this in the comments.

If you need an AVR USB bootloader, but you don’t need the encryption, we like Micronucleus. But if you need to deliver updates to users without them being able to modify (or screw up) the code in the middle, give [Dmitry]’s setup a try.

Embed with Elliot: Microcontroller Makefiles

Last time on Embed with Elliot, I began my celebration of the make command’s 40th birthday next month. We discussed using the default rules and how to augment them with your own variables defined in a makefile. Next, I’ll walk you through some makefiles that can be used for real-world microcontroller code development. This week, we’ll focus on one for the AVR platform, and later on, I’ll run through a slightly more complicated version for the ST32M series of ARM Cortex micros.

Along the way, we’ll pick up a couple of tricks, but the aim is to keep the makefiles minimal, readable, and easily extensible. Once you get a little taste of the power of writing your own makefiles, you probably won’t be able to stop adding bells and whistles — custom routines for flashing, checking the size of binaries, generating assembly listings, etc. I’ll leave the extras up to you, but you’ll eventually find that anything you do can be automated with a makefile.

Continue reading “Embed with Elliot: Microcontroller Makefiles”

SDRAM Logic Analyzer Uses An AVR And A Dirty Trick

We often see “logic analyzer” projects which are little more than microcontrollers reading data as fast as they can, sending it to a PC, and then plotting the results. Depending on how fast the microcontroller is, these projects range from adequate to not very useful.

At first glance, [esot.eric’s] logic analyzer project has an AVR in it, so it ought to be on the low end of the scale. Then you look at the specs: 32 channels at 30 megasamples per second. How does that work with an AVR in it?

The answer lies in the selection of components. The analyzer uses a 128MB SDRAM DIMM (like an older PC might use for main memory). That makes sense; the Arduino can’t store much data internally. However, it isn’t the storage capacity that makes this choice critical. It seems [esot.eric] has a way to make the RAM “free run”.

The idea is to use the Arduino (or other host microcontroller) to set up the memory. Some of the memory’s output bits feedback to the address and data lines. Then the microcontroller steps aside and the SDRAM clocks samples into its memory by itself at the prevailing clock rate for the memory.

Continue reading “SDRAM Logic Analyzer Uses An AVR And A Dirty Trick”

Hackaday Links: March 13, 2016

Way back in 2014, Heathkit was a mystery. We knew someone was trying to revive the brand, but that was about it. Adafruit pulled out all the stops to solve this mystery and came up with nothing. The only clue to the existence of Heathkit was a random person who found a geocache in Brooklyn Bridge Park. Since then, Heathkit has released an odd AM radio kit and $150 antenna. These offerings only present more mysteries, but at least [Paul] was finally rewarded for finding the Heathkit geocache. Heathkit sent [Paul] the AM radio kit. He says it’s neat and well documented.

[David] is doing his masters thesis on, “The motivation of the maker community”. That means empirical data, and that (usually) means surveymonkey. You can take his survey on the motivations of the maker community here.

America’s best loved companies, Verizon and Makerbot, together at last.

The BeagleBone Black was launched in 2013. The BeagleBone Green – a Seeed joint – showed up last August. The BeagleBone Blue, released just a few months ago, is a collaboration between the UCSD engineering department and TI. Now there’s the BeagleBone Enhanced. Yes, they should have picked another color. Perhaps ecru. The BB Enhanced sports one Gigabyte of RAM, Gigabit Ethernet, two USB ports and two USBs via an expansion header, optional serial NOR Flash for a bootloader, optional six-axis gyro, and optional barometer.

Atmel is changing a few AVRs. There is a new die for the ATMega 44, 88, 168, and the ‘Arduino chip’, the ATMega328. Most of the changes are relatively inconsequential – slightly higher current consumption in power save mode – but one of these changes is going to trip up a lot of people. The Device ID, also known as the source of the avrdude: initialization failed, rc=-1 error, has changed on a lot of chips.

Makeit Labs in Nashua, New Hampshire has a problem. They were awarded $250,000 in tax credits to help them move and renovate. Sounds like a very good problem, right? Not so: they need to sell these tax credits before the end of the month, or they lose them. They’re looking for a few businesses in New Hampshire to buy these tax credits. From [Peter Walsh]: “Under the credit program, a typical business donating $10,000 would save $9,000 on their state and federal taxes! That $10,000 donation would cost them only $1006!” Does that make sense? No, it’s taxes, of course not. If you’re a business in New Hampshire and are looking to reduce your tax burden, this is the solution.

So I mentioned MRRF, right? You should go to MRRF. It’s next weekend.

When Are 8 Bits More Than 32?

Whenever we write up a feature on a microcontroller or microcontroller project here on Hackaday, we inevitably get two diametrically opposed opinions in the comments. If the article featured an 8-bit microcontroller, an army of ARMies post that they would do it better, faster, stronger, and using less power on a 32-bit platform. They’re usually right. On the other hand, if the article involved a 32-bit processor or a single-board computer, the 8-bitters come out of the woodwork telling you that they could get the job done with an overclocked ATtiny85 running cycle-counted assembly. And some of you probably can. (We love you all!)

redblue_pillWhen beginners walk into this briar-patch by asking where to get started, it can be a little bewildering. The Arduino recommendation is pretty easy to make, because there’s a tremendous amount of newbie-friendly material available. And Arduino doesn’t necessarily mean AVR, but when it does, that’s not a bad choice due to the relatively flexible current sourcing and sinking of the part. You’re not going to lose your job by recommending Arduino, and it’s pretty hard to get the smoke out of one.

But these days when someone new to microcontrollers asks what path they should take, I’ve started to answer back with a question: how interested are you in learning about microcontrollers themselves versus learning about making projects that happen to use them? It’s like “blue pill or red pill”: the answer to this question sets a path, and I wouldn’t recommend the same thing to people who answered differently.

For people who just want to get stuff done, a library of easy-to-use firmware and a bunch of examples to crib learn from are paramount. My guess is that people who answer “get stuff done” are the 90%. And for these folks, I wouldn’t hesitate at all to recommend an Arduino variant — because the community support is excellent, and someone has written an add-on library for nearly every gizmo you’d want to attach. This is well-trodden ground, and it’s very often plug-and-play.

Continue reading “When Are 8 Bits More Than 32?”

Bye-bye ATmega328P, Hello 328PB!

We never have enough peripherals on a microcontroller. Whether it’s hardware-driven PWM channels, ADCs, or serial communication peripherals, we always end up wanting just one more of these but don’t really need so many of those. Atmel’s new version of the popular ATmega328 series, the ATmega328PB, seems to have heard our pleas.

We don’t have a chip in hand, but the datasheet tantalizes. Here’s a quick rundown of the new features:

  • Two more 16-bit timer/counters. This is a big deal when you’re writing code that’s not backed up by an operating system and relies on the hardware for jitter-free timing.
  • Two of each USART, SPI, and I2C serial instead of one of each. Good when you use I2C devices that have limited address spaces, or when you need to push the bits out really fast over SPI.
  • Ten PWM channels instead of six. This (along with the extra 16-bit timers) is good news for anyone who uses PWM — from driving servos to making music.
  • Onboard capacitive sensing hardware: Peripheral Touch Controller. This is entirely new to the ATmega328PB chip, and looks like it’ll be interesting for running capacitive sense buttons without additional ICs. It relies on Atmel’s QTouch software library, though, so it looks like it’s not a free-standing peripheral as much as an internal multiplexer with maybe some hardware-level filtering. We’ll have to look into this in detail when we get our hands on one of the chips.

So what does this mean for you? A quick search of the usual suspects shows the chips in stock and shipping right now, and there’s an inexpensive dev kit available as well. If you write your own code in C, taking advantage of the new features should be a snap. Arduino folks will have to wait until the chips (and code support) work their way into the ecosystem.

Thanks [Peter van der Walt] for the tip!

Microchip To Acquire Atmel for $3.56 Billion

Just last week, there was considerable speculation that Microchip would buy Atmel. The deal wasn’t done, and there was precedent that this deal wouldn’t happen – earlier this year, Dialog made an approach at Atmel. Now, though, the deal is done: Microchip will acquire Atmel for $3.56 Billion.

There are three main companies out there making microcontrollers that are neither ancient 8051 clones or ARM devices: TI’s MSP430 series, Microchip and Atmel. Microchip has the very, very popular PIC series microcontrollers, which can be found in everything. Atmel’s portfolio includes the AVR line of microcontrollers, which are also found in everything. From phones to computers to toasters, there’s a very high probablitiy you’re going to find something produced by either Atmel or Microchip somewhere within 15 feet of your person right now.

For the hobbyist electronic enthusiast, this has led to the closest thing we have to a holy war. Atmel chips were a little easier (and cheaper) to program, but were a little more expensive. Microchip’s chips have a very long history and proportionally more proper engineers who are advocates. PIC isn’t Arduino, though, a community that has built a large and widely used code base around the AVR family.

Microchip’s acquisition of Atmel follows several mergers and acquisitions in recent months: NXP and Freescale, Intel and Altera, Avago and Broadcom, and On Semiconductor and Fairchild. The semiconductor industry has cash and wants to spend it. What this means for the Atmel product line is left to be seen. The most popular micros probably won’t be discontinued, but if you’re using unpopular Atmel micros such as the ATtiny10 you might want to grab a reel or two before they’re EOL’d.