Harri's Tech Blog

Microchip SAM MCU Workshop

I’m not sure exactly why, but I was offered a free day workshop on one of the new Atmel MCU’s released by Microchip. After receiving the offer in an email, I immeditaly registered for the workshop in Swindon on the 18th of September. I forgot about it and only two days before was I reminded about it, which was a nice surprise at the time!

Arrival

My drive over was far from great. There was an accident on the motorway unfortunatly and I arrived almost an hour late. This meant I missed out on the introduction to the MCU the workshop is based on. The workshop was based on the SAM L10/11. A new family of MCU’s based on Atmel’s MCU designs, which Microchip acquired in 2016.

Ultra Low Power Workshop

The first session covered the range of operating power modes of the MCU.

Talk

In the talk we covered the control available over the MCU operating modes to manage power consumption.

  • Active Mode = In active mode the CPU is executing application code. Software is executing, clocks and peripherals operating.
  • Idle = In idle mode the CPU is stopped, however the peripherals are still working. This mode offers fastest wakeup time to the CPU while offering power optimization.
  • Standby mode = CPU, clocks and peripherals off. Though the RAM memory is retained and it’s possible to wake-up but with a few micro second longer than idle mode.
  • Off = Device entirely powered off. No wakeup, clocks, peripherals and the RAM is not retained.

The MCU provides functionality they termed “Sleep Walking”. This is where the peripherals can be provided a clock, without the involvement of the CPU. This means peripherals can be setup to be woken up and perform some task before returning to sleep on its own, without the CPU.

Lab

Following the talk we took a look at programming a SAM L10 dev board to demonstrate the power modes. The format for the labs was to follow through a booklet handout describing the steps we should take.

Atmel Studio IDE was used for the programming environment, which includes the tools for programming the MCU. Like most embedded programming setups, Microchip also provide a code generator tool called Atmel Start. This can be used to generate code targeting the MCU and the desired pheripherals. Atmel Start is a completly online service. Accessed either through a web browser or a window in the Atmel Studio IDE. Their reasoning for this is apparently the databases used to generate code from would a lot to download. I believe they said it was in the low hundreds of GBs.

We programmed the SAM L10 MCU to transition from active, to idle, to standby and finally off as a button was pressed on the development board. To observe that the code was working correctly, the SAM L10 power consumption could be monitored using the IDE’s power monitor tool. We could compare the observed power modes with the datasheet/document typical power consumption. The active mode used a considerable amount of power as expected (213 microamps). In idle mode almost half the active mode power (128 microamps) is used. In standby mode only a small amount of power is needed at around 0.5 microamps which is a tiny amount more than as if it were switched off, which as expected is basically 0 amps.

alt text

It’s interesting to see that in standby mode, the power consumed continously peaks and drops.

Arm Trust Zone

The second session covered the Arm TrustZone security designed into the MCU’s. In the talk we covered the security features of the LM11. The LM11 is the same as the LM10 but offers the further security features.

There were a few notable features covered like a secure boot process and physical resistance to microprobing attacks. However the main security feature discussed was the ARM trust zone. Trust zone is not actually a new design/technology and has been around since 2004 and found on some of ARM’s more advanced MCU architectures.

Trust zone works by partitioning the MCU memory into three sections. The non-secure zone where application code is written. This will be the vunerable part that may be interacting with other devices on a network etc. Then there is the secure NSC(Non-secure callable) region which essentially acts as an API for function calls to the secure zone. The main purpose of the secure NSC zone is so no memory locations are exposed to the non-secure code. Instead it just knows functions in the NSC zone. The secure zone is then where the security management code runs. This should be used to monitor and detect any suspicious behaviour and respond to it appropriatly. An example could be if the non-secure application code was compromised, the secure section could detect this and erase the application code to prevent an attempt to steal information from it.

alt text

This reminds me a lot of how a typical system OS has security levels/rings. Where the kernel will have access to important sections of memory and able to make the execution of critical code. Then application code that needs that level of control will make requests to the kernel.

I mentioned on reddit that we might see these kind of security techniques become important in modern MCU devices. Somebody commented that none of this memory paritioning was anything new and has been done for years. I agree with this but I think my point still stands that although they may have been in some use for years now, in the future as more embedded devices are joining networks it may become a feature expected in almost all the MCUs.

In the lab we programmed a SAM L11 dev board to show the Secure Zone technology in use but didn’t go as far as to test and demonstrate it.

##Follow up

At the end, before I left. One of the members of the team let me know if I dropped him an email they would be able to send me one of the dev boards to test out further. I was keen to continue working with the SAM MCU. Unfortunatly I have not heard anything back from him weeks later. I may still get to ordering one at somepoint as I really like what they have to offer.