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

Suggestion: use "config.mk" model for easily customizing build flags #5

Closed
PaulBatchelor opened this issue Mar 6, 2018 · 10 comments
Closed

Comments

@PaulBatchelor
Copy link
Contributor

A configuration file for Make would be a nice thing to have. I thought I would run it by you before making a PR.

For me, this would be necessary because my cross-compiler toolchains are in weird, non-standard locations.

The classic example of this is with dwm. I would probably implement something similar to my own projects Soundpipe and Sporth.

What do you think?

@canselcik
Copy link
Owner

Yeah I wouldn't be against it. You can definitely focus on improving the config and build steps of the C implementation. There also might be some value in making it download and extract the Poky Toolchain before a build, or at least check if arm-linux-gnueabihf-gcc exists and can be used to build executables.

@PaulBatchelor
Copy link
Contributor Author

download and extract Poky Toolchain before a build

It would be cleaner to put this in a shell script that the user explicitly calls rather than try to have Make do that.

or at least check if arm-linux-gnueabihf-gcc exists

The ?= operator should do the job, as it will set CC to that value by default unless overwritten. A config file could override those defaults too.

@PatrickGretzki
Copy link

Its seems, that the "nightly" channel is needed for compiling the rust example ... otherwise "mock_derive" won't compile

@canselcik
Copy link
Owner

@PatrickGretzki Thanks for pointing that out. All the mocking code was introduced with 517a044, you can do git revert 517a044 as a temporary workaround (or use the nightly channel) as we aren't even leveraging these mocking capabilities yet.

Let me know if you have further comments/suggestions, especially since PatrickGretzki/paperOS looks like we have quite an overlap there. :)

@PatrickGretzki
Copy link

I just started using rust, so I will have many questions in the next days :)
Otherwise regarding "PaperOS" - in the moment I try to collect ideas and features for a smart replacement of "xochitl". As soon as the concept is ready and I tested some design issues, we should work together to make it reality.

@PatrickGretzki
Copy link

Hey. its me again- The cross-compiler is running and I can compile simple programs for the remarkable. But building your example/lib is still not working. The package "lua52-sys" throws a panic error at compiling
Compiling lua52-sys v0.1.1
error: failed to run cusom build command for 'lua52-sys v0.1.1
process didn't exit successfully
[...]
Internal error occurred: Failed to find tool. Is 'cortexa9hf-neon-poky-linux-gnueabihf' installed?
`~/.cargo/registry/src/.../gcc-0.3.54/src/lib.rs:1670:5``

Any ideas guys ?

@canselcik
Copy link
Owner

canselcik commented Mar 30, 2018

@PatrickGretzki Do you have the toolchain installed? What platform are you building on? Linux or OSX?

I can help you through all the build issues. Let me know.

@canselcik
Copy link
Owner

canselcik commented Mar 30, 2018

You can also see my latest commit e48f949 which should take care of the nightly requirement due to mock_derive.

Back to your previous question; if you installed the toolchain via your OS's package manager it is likely already in your $PATH. If you used the poky toolchain, which it looks like you did, then make sure you are sourceing the environment script.

➜  libremarkable git:(master) ls -latr /opt/poky/2.1.3
total 64
-rw-r--r-- 1 root root  3203 Feb 15 23:11 environment-setup-cortexa9hf-neon-poky-linux-gnueabi
-rw-r--r-- 1 root root   121 Feb 15 23:11 version-cortexa9hf-neon-poky-linux-gnueabi
-rw-r--r-- 1 root root 44713 Feb 15 23:11 site-config-cortexa9hf-neon-poky-linux-gnueabi
drwxr-xr-x 3 root root  4096 Feb 15 23:12 .
drwxr-xr-x 4 root root  4096 Mar  5 12:26 sysroots
drwxr-xr-x 3 root root  4096 Mar 28 01:09 ..

In this case you would want to do source /opt/poky/2.1.3/environment-setup-cortexa9hf-neon-poky-linux-gnueabi, which should make sure the compiler is in your $PATH.

Of course you will need to do this following step for the poky gcc, I'd recommend giving it the full path in your case.

$ cat ~/.cargo/config
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"

@PatrickGretzki
Copy link

PatrickGretzki commented Mar 30, 2018

Okay - Today I started from scratch to ensure, that I can reproduce the error and have a stable environment. I did not use the "poky" tool chain but the default arm-gcc.

- Install minimal ubuntu linux image in VM
http://de.releases.ubuntu.com/artful/ubuntu-17.10.1-server-i386.iso

- Install Rust
curl https://sh.rustup.rs -sSf | sh

- Setup rust for nightly channel
curl -s https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly
rustup default nightly
or
rustup install nightly
rustup default nightly

- Install cross-compiler toolchain
sudo apt-get install -qq gcc-arm-linux-gnueabihf

- Install cross compiled standard crates
rustup target add armv7-unknown-linux-gnueabihf

- Configure cargo for cross compilation
mkdir -p ~/.cargo
touch ~/.cargo/config
cat >>~/.cargo/config <<EOF
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
EOF

- OPTIONAL - Test cross-compiler with empty project
cargo new --bin dummy
cd dummy
cargo build --release --target=armv7-unknown-linux-gnueabihf

- Clone repository and compile
git clone https://github.com/canselcik/libremarkable.git
make

So ... the cross-compiler is working for a simple "hello world". For your project I had some minor drawbacks. The nightly build is a must. Also you need the package "gcc" for building some crates (e.g. "regex"). Now everything is working fine - Thanks !

@canselcik
Copy link
Owner

canselcik commented Mar 30, 2018

Awesome. Glad to hear that @PatrickGretzki. Thanks for the detailed description of the steps you had to follow. I will include them in the wiki later today once I have some free time.

In the meantime, if you haven't looked at all the pages on the wiki, I definitely recommend it. It has a lot of fresh information.

https://github.com/canselcik/libremarkable/wiki

Also since you are one of the first people I know that ran the demo example on his device, here are some interesting features you might want to try:

Pressing the MIDDLE button will clear the lower half of the screen.
Pressing the LEFT button will toggle the touch action between: none, circles and bezier.
Pressing the RIGHT button will draw a black rectangle on the screen for as long as the button is kept pressed.

The Rust logo at the upper right corner has an active region set for it, which associates a function with the onTouch event for a provided rectangle. So touching that logo will trigger an action as well.

I would also recommend you to do a git pull since I have improved the actual plotting of the line quite a lot and pushed my changes just now with 359ccec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants