<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Raspberry Pi | Cyrille Froehlich</title>
    <link>https://cyrille.hazeliris.com/tag/raspberry-pi/</link>
      <atom:link href="https://cyrille.hazeliris.com/tag/raspberry-pi/index.xml" rel="self" type="application/rss+xml" />
    <description>Raspberry Pi</description>
    <generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Sat, 20 Mar 2021 10:45:24 +0000</lastBuildDate>
    <image>
      <url>https://cyrille.hazeliris.com/media/icon_hua2ec155b4296a9c9791d015323e16eb5_11927_512x512_fill_lanczos_center_2.png</url>
      <title>Raspberry Pi</title>
      <link>https://cyrille.hazeliris.com/tag/raspberry-pi/</link>
    </image>
    
    <item>
      <title>Gitea ARM crossbuild (with GoModules)</title>
      <link>https://cyrille.hazeliris.com/post/2021/03/22/gitea-arm-crossbuild-with-go-modules/</link>
      <pubDate>Sat, 20 Mar 2021 10:45:24 +0000</pubDate>
      <guid>https://cyrille.hazeliris.com/post/2021/03/22/gitea-arm-crossbuild-with-go-modules/</guid>
      <description>&lt;p&gt;Upgrading to Gitea 1.13.4 didn&amp;rsquo;t go as planned and it failed to
compile the go-sqlite3 module &lt;a href=&#34;https://cyrille.hazeliris.com/post/2019/12/27/gitea-arm-crossbuild/&#34;&gt;with my previous setup&lt;/a&gt;. While crossbuilding, the CGO parameter is
automatically disabled (i.e. compiling is done with CGO_ENABLED=0) but
the go-sqlite3 module won&amp;rsquo;t build anymore if this option is not set
(probably require some optimisation in C and a pure Go implementation
won&amp;rsquo;t fit anymore). As a consequence of enabling this option, setting
the environment variable CC to the C cross-compiler explicitly is now
mandatory to ensure modules don&amp;rsquo;t target the wrong platform.&lt;/p&gt;
&lt;p&gt;A recent Go compiler will also have the Go Modules support enabled,
thus we can now simplify the build process with a more usual
checkout/make pattern.&lt;/p&gt;
&lt;p&gt;Dockerfile sample:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;FROM golang:latest

RUN dpkg --add-architecture armhf

RUN apt-get update
RUN apt-get install -y --no-install-recommends curl git build-essential crossbuild-essential-armhf

SHELL [ &amp;quot;/bin/bash&amp;quot;, &amp;quot;--login&amp;quot;, &amp;quot;-c&amp;quot; ]

ARG NVM_VERSION=&amp;quot;0.37.2&amp;quot;
RUN\
  ( export PROFILE=$HOME/.profile;\
    /usr/bin/curl -o- &amp;quot;https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh&amp;quot; | /bin/bash )

ARG NODE_VERSION=&amp;quot;14.15.3&amp;quot;
RUN\
  nvm install &amp;quot;${NODE_VERSION}&amp;quot; &amp;amp;&amp;amp;\
  nvm use &amp;quot;v${NODE_VERSION}&amp;quot; &amp;amp;&amp;amp;\
  nvm alias default &amp;quot;v${NODE_VERSION}&amp;quot;

ARG YARN_VERSION=&amp;quot;1.22.10&amp;quot;
RUN\
  ( export PROFILE=$HOME/.profile;\
    /usr/bin/curl -o- -L &amp;quot;https:/yarnpkg.com/install.sh&amp;quot; | /bin/bash -s -- --version ${YARN_VERSION})

RUN\
  ( echo ;\
    echo &#39;source $HOME/.nvm/nvm.sh&#39;;\
    echo &#39;export PATH=/go/bin:/usr/local/go/bin:${PATH}&#39;; ) &amp;gt;&amp;gt; $HOME/.profile

WORKDIR /go

ENV GOARM=7
ENV GOARCH=arm
ENV GOOS=linux
ENV CGO_ENABLED=1
ENV CC=arm-linux-gnueabihf-gcc

ARG GITEA_VERSION=&amp;quot;v1.13.4&amp;quot;
RUN git clone --shallow-submodules --recurse-submodules --branch &amp;quot;${GITEA_VERSION}&amp;quot; --depth 1 https://github.com/go-gitea/gitea.git gitea

ENV TAGS=&amp;quot;bindata sqlite sqlite_unlock_notify&amp;quot;
RUN cd gitea &amp;amp;&amp;amp; make build
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which we can run with (replace the host_output_dir with some folder on the host):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;docker build -t gitea-arm-builder .
docker run --rm -v [host_output_dir]:/output gitea-arm-builder cp /go/src/code.gitea.io/gitea/gitea /output/gitea-1.13.4-arm-linux
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>Gitea ARM crossbuild</title>
      <link>https://cyrille.hazeliris.com/post/2019/12/27/gitea-arm-crossbuild/</link>
      <pubDate>Sun, 03 Nov 2019 12:45:24 +0000</pubDate>
      <guid>https://cyrille.hazeliris.com/post/2019/12/27/gitea-arm-crossbuild/</guid>
      <description>&lt;p&gt;Instead of building the &lt;a href=&#34;https://gitea.io/&#34; title=&#34;Self-hosting git server&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Gitea&lt;/a&gt; binary
on a Raspberry PI, we can speed up things a bit by crossbuilding from some other computer
with more punch. Recent version of &lt;em&gt;Gitea&lt;/em&gt; will need nodejs/npm to be available at build time,
so we&amp;rsquo;ll install this too.&lt;/p&gt;
&lt;p&gt;Dockerfile sample:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;FROM golang:latest

RUN dpkg --add-architecture armhf

RUN apt-get update
RUN apt-get install -y --no-install-recommends curl git build-essential crossbuild-essential-armhf

SHELL [ &amp;quot;/bin/bash&amp;quot;, &amp;quot;--login&amp;quot;, &amp;quot;-c&amp;quot; ]

ARG NVM_VERSION=&amp;quot;0.37.2&amp;quot;
RUN\
  ( export PROFILE=$HOME/.profile;\
    /usr/bin/curl -o- &amp;quot;https://raw.githubusercontent.com/creationix/nvm/v${NVM_VERSION}/install.sh&amp;quot; | /bin/bash )

ARG NODE_VERSION=&amp;quot;14.15.3&amp;quot;
RUN\
  nvm install &amp;quot;${NODE_VERSION}&amp;quot; &amp;amp;&amp;amp;\
  nvm use &amp;quot;v${NODE_VERSION}&amp;quot; &amp;amp;&amp;amp;\
  nvm alias default &amp;quot;v${NODE_VERSION}&amp;quot;

ARG YARN_VERSION=&amp;quot;1.22.10&amp;quot;
RUN\
  ( export PROFILE=$HOME/.profile;\
    /usr/bin/curl -o- -L &amp;quot;https:/yarnpkg.com/install.sh&amp;quot; | /bin/bash -s -- --version ${YARN_VERSION})

RUN\
  ( echo ;\
    echo &#39;source $HOME/.nvm/nvm.sh&#39;;\
    echo &#39;export PATH=/go/bin:/usr/local/go/bin:${PATH}&#39;; ) &amp;gt;&amp;gt; $HOME/.profile

WORKDIR /go

ENV GOARM=7
ENV GOARCH=arm
ENV GOOS=linux

ARG GITEA_VERSION=&amp;quot;v1.12.6&amp;quot;

RUN go get -d -u code.gitea.io/gitea

RUN cd /go/src/code.gitea.io/gitea &amp;amp;&amp;amp; git checkout ${GITEA_VERSION}

RUN cd /go/src/code.gitea.io/gitea &amp;amp;&amp;amp; TAGS=&amp;quot;bindata sqlite sqlite_unlock_notify&amp;quot; make build
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which we can run with (replace the host_output_dir with some folder on the host):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;docker build -t gitea-arm-builder .
docker run --rm -v [host_output_dir]:/output gitea-arm-builder cp /go/src/code.gitea.io/gitea/gitea /output/gitea-1.12.5-arm-linux
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My real setup is a little bit more involved as it uses Docker-Compose and multi-staged Dockerfiles
to share the nodejs install and optimize the build.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Gitea ARM7 build (Raspberry PI 2)</title>
      <link>https://cyrille.hazeliris.com/post/2019/11/03/build-gitea-rpi/</link>
      <pubDate>Sun, 03 Nov 2019 12:45:24 +0000</pubDate>
      <guid>https://cyrille.hazeliris.com/post/2019/11/03/build-gitea-rpi/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m hosting my projects code on a &lt;a href=&#34;https://gitea.io/&#34; title=&#34;Self-hosting git server&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Gitea&lt;/a&gt;
instance running on a Raspberry PI. Thing is, the last Raspbian update broke the gitea
binary: probably some change in the kernel or libc. The official gitea build for ARM
kept crashing with a segmentation fault before even entering the main. Of course, latest
gitea builds were also broken. Only building Gitea from source eventually fixed the issue.&lt;/p&gt;
&lt;p&gt;I had to bump the swapfile size a bit as the build process burst to 1.2Go of memory
(RPI2 have 1Go, and default swap was set to 100Mo&amp;hellip; Murphy strikes again) :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ dphys-swapfile swapoff
# Edit the size in /etc/dphys-swapfile
# Then recreate the swap
$ dphys-swapfile setup
$ dphys-swapfile swapon
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Grab an up-to-date golang compiler:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ docker pull golang
$ docker run -it golang bash
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, inside the container, retrieve the source and build:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;% export GOOS=linux GOARCH=arm GOARM=7
% go get -d -u code.gitea.io/gitea
% cd $GOPATH/src/code.gitea.io/gitea
% git checkout v1.12.5
% TAGS=&amp;quot;bindata sqlite sqlite_unlock_notify&amp;quot; make build
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Retrieve the file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ docker cp [your container name]:/go/src/code.gitea.io/gitea/gitea gitea-1.12.5-linux-arm-7
# My service file references the gitea symlimk, just point to the new file
$ ln -sf gitea-1.12.5-linux-arm-7 gitea
$ systemctl restart gitea
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
  </channel>
</rss>
