Skip to content
This repository was archived by the owner on Jul 6, 2019. It is now read-only.

Build Zinc with Cargo #219

Closed
wants to merge 1 commit into from
Closed

Build Zinc with Cargo #219

wants to merge 1 commit into from

Conversation

bharrisau
Copy link
Contributor

Not finished, but I'm just working through it now. You can build the zinc rlib with

cargo build --target thumbv7em-linux-eabi

I've also removed the macro_ioreg crate and merged into the single ioreg crate as part of this. Next steps are doing the flexible target specification now that is has landed and also making changes to include all the static libs in the one go.

@farcaller
Copy link
Member

Would it be hard to drop-in replace rake build code with cargo invocation so that rake build_all is still relevant? That would facilitate testing this PR.

@farcaller
Copy link
Member

(replace for relevant parts, e.g. zinc crate)

@bharrisau
Copy link
Contributor Author

I'm playing with that at the moment. Cargo can handle tests and building
examples, but it doesn't do the size stuff at the end. Probably better to
go through rake.

@bharrisau
Copy link
Contributor Author

After fighting with Cargo for a while, I gave up and created deps for libcore and librlibc. They are very simple at the moment, but once the new Cargo nightly lands I can make a build.rs executable that is smarter about it.

@bharrisau
Copy link
Contributor Author

So the plan at this stage is to have an apps directory for each platform, and to have a Cargo build for the apps in each.

@bgamari
Copy link
Contributor

bgamari commented Nov 7, 2014

@bharrisau this seems a bit unfortunate as we will somehow need to duplicate the apps, some of which should at least in principle be platform independent (says the person responsible for duplicating app_blink for the K20). I suppose we could symlink them but it still seems a bit silly. Why is this necessary?

@bharrisau
Copy link
Contributor Author

Mostly because it make my life easier (happy to refactor later, this has been on my TODO for so long I just really want to get this done), plus each platform has different features so the example apps aren't 100% portable.

@bharrisau
Copy link
Contributor Author

How is this looking? I had to move the isr stuff out to the application level to get rid of all the linker stuff. Ideally a Zinc/PlatformTree macro will handle generating them.

It builds a suitable ELF binary so I'm pretty happy. I'll port a blink example over to show peripherals and pinmaps next.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 9, 2014

I don't think the app layer is the proper placement for linker layout. The linker layout is not app dependent is it?

The layout.ld for K20 is only for MK20DX32 , I would use more specific naming as it would allow us to add there another MK20Dxxxx.

In general, looks better to me as it was.

#[link_section=".isr_vector"]
#[allow(non_upper_case_globals)]
#[no_mangle]
pub static ISRVectors: [Option<unsafe extern fn()>, ..ISRCount] = [
Copy link
Contributor

Choose a reason for hiding this comment

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

I would name this ISRVectors as Core interrupts. Which tends me to an idea, even this could be added based on the core selected. Not part of K20 chip specifications. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue with interrupt handlers is that Rust doesn't do weak/optional functions very well. The implementation of interrupt handlers is app specific (as the app chooses to enable them).
Happy to take suggestions for this, should Zinc provide a generic handle that passes the interrupt to an event handler in the main thread?

Copy link
Contributor

Choose a reason for hiding this comment

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

If there's nothing like weak linkage, there could be an interrupt manager. Dynamically reallocate vector table once the ISR are used. It would manage interrupts for HAL layer as well (To register interrupt, deregister).
I don't think isr handlers belong to an app layer.

I am yet not familiar with event handler, if you can point me to the source.

This (how are interrupts managed) might be suitable for separate discussion, to leave it out of this pull request.

path = "src/zinc/lib.rs"

[dependencies.rlibc]
git = "https://github.com/bharrisau/rust-librlibc.git"
Copy link
Contributor

Choose a reason for hiding this comment

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

@mcoffin
Copy link
Contributor

mcoffin commented May 31, 2015

This can probably be closed now that #285 has landed.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants