Preloaded Image Doesn't Start

I have installed openBalena 2.0.0 on an EC2 instance and installed balena_cli v12.11.0 to deploy my Raspberry Pi Zero W application. (This link says why I have selected such versions - OpenBalena: Cannot create application)

And then, I used balena_cli v11.7.10 to preload my application to my image. (This link also says why I had to use a different version - https://github.com/balena-io/balena-cli/issues/2068#issuecomment-713178034

But I cannot see my application running on the preloaded balenaOS.
(I can see my image by balena images command though)

The only problem is the internet connection. At the beginning, there is no internet connection and my application will launch the wifi-connect to let users configure the wifi by their phone or tablet.

However, I have nothing to do as the application didn’t launch… :confused:

Does the openbalena application need the internet connection to start the application?

Thanks!

Hi, openBalena and balenaCloud applications are the same. Only the backend to which the device registers itself is different. What you describe does not seem to be related to the particular backend (openBalena), but it seems more like you are hitting a some error with your application which makes wifi-connect not to start, or there was some problem during preloading.

Do you run a development version of the OS? When running a development image you may ssh to the device by using balena ssh <IP address> and inspect what is happening on the device. You may look at the device logs with journalctl. You may check from inside the device whether the containers are working and so on.

As an advice have you tried running your application on top of balenaCloud? It allows up to ten free devices, so you may get a better feeling of how everything works there - initial application development is much easier for beginners. Once you get more comfortable with the OS on the device itself, it should be really easy to switch to your openBalena instance and continue further.

Also by using balenaCloud it would be easier for us to help you out with diagnosing this as you can share a dashboard link with us after you enabled support access there.

Thanks,
Zahari

Hi, @majorz

Thanks for your reply.

  1. I have been using balena for over 2 years in many projects. I would say I am not a beginner! lol
  2. I didn’t configure the wifi of the development image. Just did preload my application. So, no internet connection at the beginning.
  3. As I said, I could see my image with balena images command, but balena ps or balena ps -a doesn’t display my container running.

Seems my container is not triggered at all?
If the issue in on the container itself, it should be displayed by balena ps -a command?

Thanks!

Sorry about my confusion :)))

That sounds strange indeed. A container should not need Internet to be run as that is a common use-case for preloading. I assume you have some access to the Pi Zero device since you are running the balenaEngine inside the device. Can you please do a fresh reboot and then run full journalctl and balena logs resin_supervisor and send us the output?

There should be some indication of what could have possibly going wrong there which will give us further clues on how to go on further.

Thanks,
Zahari

The fresh reboot is just in case some log rotation has occurred.

Hi, @majorz

Sorry for the delay.

Is it mandatory to configure the preloaded image with balena os configure command here? https://www.balena.io/docs/reference/balena-cli/#os-configure-image

I have never configured the image, just preloaded my application.

Thanks!

Hi, configuring image should not be required to make application work. Getting logs as Zahari suggested is the best way to investigate the issue.

@majorz

Okay, here is the result on my hostOS: https://pastebin.com/WnyWdSBx

As you could see, I have executed some commands to verify that the application was preloaded correclty.

Looking forward to your reply soon.

Thanks!

Hi Webster. I believe the issue is related to local mode. When a device is in local mode it will not start the application containers. Did you place the device in local mode somehow?

Hey, there.

Hmm, I had downloaded the latest development image of RPi Zero W and preloaded.

Are you sure that the production image would start applications automatically?

Cheers,
Wester.

Hi Wester,
Yes both development and production images should start your applications automatically.
What is strange though is that (according to the logs you sent) the device is starting up in local mode (i.e. as an unmanaged device, not tracking releases from the cloud). This may explain the app not starting automatically. Do you know of any reason why the device is set to local mode?
Thank you

How do we set the image to local mode?

I have just downloaded this image and preloaded after deploying my application.

ubuntu@ubuntu-desktop:~$ balena apps
ID APP NAME  DEVICE TYPE  ONLINE DEVICES DEVICE COUNT
1  yokosoApp raspberry-pi 0              0
ubuntu@ubuntu-desktop:~$ balena preload rpi_zero_image.img --add-certificate <MY OPENBALENA CERT FILE> --app yokosoApp --commit current --splash-image my_splash.jpg

Note that I used v12.11.0 when deploying the app, and used v11.17.0 when I preload the image.

Does this cause the issue?

Hi Webster,
The node versions should not be a factor. We will try to retrace your steps to see if we can find why the device is getting set to local mode.
Thank you

1 Like

Hi Wester, One question came to mind - how are you setting your wifi credentials?

Hi Wester, sorry, please disregard my earlier question about wifi credentials (since you are using wifi-connect). We are currently investigating.

1 Like

@srlowe

Did you try to download the latest image and flash your micro sd card?
https://api.balena-cloud.com/download?deviceType=raspberry-pi&version=2.54.2+rev1.dev&fileType=.zip

I just downloaded the image again and flashed.

And localMode in /boot/config.json is true!

Best,
Wester.

Just tried 2.48 version again and same… localMode in config.json file is true!

Do I have to change it manually to get my application running automatically?

Will give it a try anyway.

Hi Wester

I was just able to reproduce your issue with my PiZero, and I think I understand the issue better now.

The image you are using is a standalone balenaOS: https://www.balena.io/docs/reference/OS/overview/2.x/#standalone-balenaos

The images are what balena calls “unmanaged” they do not have any configuration to connect to an openBalena or balenaCloud. Unmanaged images start in local mode by default so that they can be used locally since they do not connect to a backend.

Local mode does not load applications from a backend and also does not load preloaded applications.

You mentioned you installed openBalena, if you want the device to connect to your openBalena it works the same way to balenaCloud. Create the application in openBalena and then add device and download the image from there, those images will come pre-configured. You can also preload that image and since its not unmanaged it will not start in local mode and you should see your application running fine.

1 Like

Whoops, thanks for your clarification!

Hi Wester. I also just realized that you don’t need to download the image via your openBalena. You CAN use balena os configure I had not used it before and a colleague mentioned its more convenient for them than using the UI sometimes. I think you will need to configure the image before preloading.

1 Like