Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards: ikea-tradfri: add support #8047

Merged
merged 2 commits into from Nov 21, 2017

Conversation

basilfx
Copy link
Member

@basilfx basilfx commented Nov 15, 2017

Last week I found out that the IKEA TRÅDFRI lighting products and accessories use the Silicon Labs EZR32MG1P microcontroller. Let it be a coincidence that the Thunderboard Sense (#7929) which was merged this week, uses the same CPU!

Now if we look into their line of products, it happens that they use the same CPU module in all(?) of their products: here, here and here. Nonetheless, you can isolate them from the product, and use them for your own ideas, or leave them in and flash a custom firmware.

The MCU is a ARM Cortex M4 with 256 kB of flash. It's quite packed (including hardware crypto), flexible pin mapping and has an integrated radio which supports Thread, ZigBee Light Link and more.

It won't surprise me if people buy the cheapest light available (the GU-10 I used costed me 6,99 euro) and upgrade, hack or repurpose them. Let RIOT-OS be one of the first to support them :-)

This PR is a quick port to this new platform. I have more information on the module over here and a demonstration video here. For flashing you need to connect a JTAG/SWD compatible debugger, but I can flash it the exact same way as the Thunderboard Sense when I use SEGGER JLink. You do not even have to remove the module.

@basilfx basilfx added Area: boards Area: Board ports Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Nov 15, 2017
@basilfx
Copy link
Member Author

basilfx commented Nov 15, 2017

This will void the warranty of your IKEA product.

@miri64
Copy link
Member

miri64 commented Nov 15, 2017

Is there a radio on-board (and do we support it already)?

@basilfx
Copy link
Member Author

basilfx commented Nov 15, 2017

It has a radio on-board, but we don't support it yet. But now I have more motivation to do so :-)

It would be a nice product/board for demo purposes.

@miri64
Copy link
Member

miri64 commented Nov 15, 2017

It would be a nice product/board for demo purposes.

Yes definitely! I've been waiting for hacks like this basically since day one of my contribution (but never found the time to do it myself 😞).

@kYc0o
Copy link
Contributor

kYc0o commented Nov 15, 2017

Eeeexcelleeeent!!! I was thinking about these products since I was aware of them, but I'm glad you also investigated them!

I'll try to grab some and hack them with RIOT.

@kYc0o kYc0o assigned kYc0o and haukepetersen and unassigned haukepetersen Nov 15, 2017
@miri64
Copy link
Member

miri64 commented Nov 15, 2017

I guess I have to guess I have to go to IKEA again (damn it I was saving up for a new PC!!1! 😜)

@haukepetersen
Copy link
Contributor

Awesome!!! My wife will be sooo happy that I am now motivated to go to ikea (besides the usual hot-dog motivation) :-)

Will review do a review right away.

* @{
*/
#define LED0_PIN GPIO_PIN(PA, 1)
#define LED1_PIN GPIO_PIN(PB, 13)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From your video I take that this pin is connected to the FET switching the actual light, right? So what is LED0 connected to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to think about this, and see what is useful. In my case, PA1 was also soldered, but I don't know what it does (haven't traced it properly).

Since the same board is used in different light bulbs or accessories, I had this idea of defining different pins on an additional compiler flag. E.g. IKEA_PRODUCT=ligthbulb or something like that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. So I guess lets leave it for now and see what further reverse engineering brings...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After closer inspection, it seems that PA1 is only connected for fixing the PCB. It leads to a dead end (missing resistor).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's connected in the more expensive versions? The versions that can change the white color between warm and cold (not only brightness) have 2 different LED-types for this - cold whites and warm whites. So there's probably one color on each connector?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is definitely possible. In other teardowns you can see that more pins are connected.

Copy link
Contributor

@haukepetersen haukepetersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One tiny remark, else looking great!

.dev = USART1,
.mosi_pin = GPIO_PIN(PD, 15),
.miso_pin = GPIO_PIN(PD, 14),
.clk_pin = GPIO_PIN(PD, 13),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything connected to these pins (or rather: are they accessible)? If not, we might just want to skip the SPI configuration all together for this board?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an additional SPI flash that we might want to access.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, so never mind.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure, but based on reading the JEDEC ID and Product Identification, it seems that a 2Mbit flash by Integrated Silicon Solution Inc. (part number IS25LQ020B) is used.

@miri64 miri64 added the PR-award-nominee Deprecated. Will be removed soon. label Nov 16, 2017
@kaibeckmann
Copy link

Hey thats cool!

Based on your work I started with the radio driver and support for the Silicon Labs Dev-boards. It is still work in progress and based on the RIOT version from February, but could be a starting point to get RIOT on light bulbs :)

@basilfx
Copy link
Member Author

basilfx commented Nov 17, 2017

@kaibeckmann That's cool! I can help you if you want!

I am also working on another PR which will improve support for EFM32, based on feedback by @haukepetersen. Hope to create a PR this weekend.

In the mean time, I have updated https://github.com/basilfx/TRADFRI-Hacking and added some work-in-progress schematics and PCB designs for development. I first need another trip to IKEA!

@kaibeckmann
Copy link

@basilfx Yeah that could speed things up!
Regarding the EFM32 support: I ran in some issues with the radio stuff there. I'll try to sum it up and send you a mail. Furthermore, I started to put the gecko-sdk in an package. At the moment I only pull the radio driver blob from it and use the header files for the RAIL-API. Maybe that could be a used for the rest of the emlib-stuff as well?

Copy link
Contributor

@haukepetersen haukepetersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concerns are addressed -> ACK ACK ACK

@haukepetersen
Copy link
Contributor

@kaspar030 I know you won't like the duplicated code in this PR either, but I'd say we merge this anyway and wait for the results of #8058 and clean-up/unify around the EFM32-based boards once a structure is decided.

@basilfx basilfx added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 17, 2017
@kYc0o
Copy link
Contributor

kYc0o commented Nov 17, 2017

@basilfx is there a way to backup the existing firmware? (in case of we want to come back to the default behaviour).

@kYc0o
Copy link
Contributor

kYc0o commented Nov 17, 2017

Just FYI, there are efforts to communicate with these things using aiocoap, you might be interested in this issue.

@basilfx
Copy link
Member Author

basilfx commented Nov 17, 2017

@kYc0o Yes, I've managed to backup a copy of the firmware. I haven't tried to flash it back, but I will try that tonight (just went to IKEA to buy some more lights).

@kYc0o
Copy link
Contributor

kYc0o commented Nov 17, 2017

There is this effort too.

@basilfx
Copy link
Member Author

basilfx commented Nov 17, 2017

I can confirm that the light will still work after downloading the binary (256 kB), erasing the chip, and then uploading the binary again (including power cycling). I did have to re-pair the light bulb, but I think that is not due to flashing. It even defaulted to last brightness.

img_0983

@miri64
Copy link
Member

miri64 commented Nov 17, 2017

Nobody dares to merge this awesome feature?

@basilfx
Copy link
Member Author

basilfx commented Nov 17, 2017

I have a small fix for the SPI pins. I have confirmed that it works, because I can read the SPI chip.

@kYc0o
Copy link
Contributor

kYc0o commented Nov 17, 2017

Nobody dares to merge this awesome feature?

It was maybe acked too fast 😉

@basilfx
Copy link
Member Author

basilfx commented Nov 17, 2017

Now also featured on Hackaday: https://hackaday.com/2017/11/17/hacking-the-ikea-tradfri-light-bulb/

@kYc0o
Copy link
Contributor

kYc0o commented Nov 17, 2017

Waaaaao!!! Congrats! 😃

@miri64
Copy link
Member

miri64 commented Nov 18, 2017

Whoopwhoop \o/

@miri64
Copy link
Member

miri64 commented Nov 18, 2017

Nobody dares to merge this awesome feature?

It was maybe acked too fast 😉

Can you point me to the comment where this is stated? I couldn't find it. (and why wasn't the review dismissed then 😉?)

@basilfx basilfx added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Nov 18, 2017
@basilfx
Copy link
Member Author

basilfx commented Nov 18, 2017

If somebody wants to re-ACK my last commit (d710676), than I will squash, rebase and commit when Murdock agrees!

@kYc0o
Copy link
Contributor

kYc0o commented Nov 19, 2017

Can you point me to the comment where this is stated? I couldn't find it. (and why wasn't the review dismissed then 😉?)

I didn't mean too fast in the sense of "bad-acked" but in the sense that several changes came just after it was acked which can also belong to this PR. We could have merged this as it was acked (since it was OK to ack it, everything worked as expected and the comments were addressed), and the modifications and improvements which came afterwards would have been part of another PR.

Thus, nothing to dismiss, nothing to complain, just a personal impression. Waiting a bit more before merge it gave us other features and better understanding.

MEMORY
{
rom (rx) : ORIGIN = 0x00000000, LENGTH = 262144
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 31744
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened with the remaining 1K of RAM?

Copy link
Member Author

@basilfx basilfx Nov 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I recall correctly, 1 KiB is reserved for the (proprietary) radio (driver). However, I've double-checked with the Gecko SDK, but that number is correct :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I suppose that is managed internally since I don't see any specific instruction in the ld you cite on which they make use of the last 1K of RAM. Though it looks a bit strange but if it works let's continue this way.


MEMORY
{
rom (rx) : ORIGIN = 0x00000000, LENGTH = 262144
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

262144 can be written as 256K to make it a little bit more friendly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change that, but I have another PR coming up that will use the default Cortex-M linker scripts :-)

@haukepetersen
Copy link
Contributor

re-ACK your SPI fix -> please squash and I will be happy to press the big green button :-)

@basilfx basilfx added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Nov 20, 2017
@basilfx
Copy link
Member Author

basilfx commented Nov 21, 2017

@haukepetersen Go ahead :-)

@haukepetersen
Copy link
Contributor

My pleasure! -> go

@haukepetersen haukepetersen merged commit e5083ab into RIOT-OS:master Nov 21, 2017
@miri64
Copy link
Member

miri64 commented Nov 21, 2017

🎉

@aabadie aabadie added this to the Release 2018.01 milestone Jan 18, 2018
@basilfx basilfx deleted the feature/ikea-tradfri branch January 9, 2020 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR PR-award-nominee Deprecated. Will be removed soon. Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants