Commit 8ef4ab12 authored by Florian Kaltenberger's avatar Florian Kaltenberger

removing rest of USERSPACE_TOOLS (unused or depricated)


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7224 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent b9ddfe65
This diff is collapsed.
updatefw: updatefw.c
$(CC) updatefw.c -o updatefw -I../../../targets/ARCH/EXMIMO
clean:
rm -f updatefw
This diff is collapsed.
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenAirInterface is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*============================================================================
File: elftypes.h
Include file for Elf types. Define elf types for Elf structures.
Copyright Hewlett-Packard Co. 1995. All rights reserved.
============================================================================*/
#ifndef ELFTYPES_INCLUDED
#define ELFTYPES_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __LP64__
typedef unsigned int Elf32_Addr; /* Unsigned program address */
typedef unsigned int Elf32_Off; /* Unsigned file offset */
typedef int Elf32_Sword; /* Signed large integer */
typedef unsigned int Elf32_Xword; /* Unsigned large integer */
#else
typedef unsigned long Elf32_Addr; /* Unsigned program address */
typedef unsigned long Elf32_Off; /* Unsigned file offset */
typedef long Elf32_Sword; /* Signed large integer */
typedef unsigned long Elf32_Xword; /* Unsigned large integer */
#endif
typedef unsigned int Elf32_Word; /* Unsigned large integer */
typedef unsigned short Elf32_Half; /* Unsigned medium integer */
typedef unsigned char Elf32_Char; /* Unsigned tiny integer */
typedef unsigned char Elf32_Byte; /* Unsigned tiny integer */
#ifdef __LP64__
typedef unsigned long Elf64_Addr;
typedef unsigned long Elf64_Off;
typedef unsigned long Elf64_Xword;
typedef long Elf64_Sxword;
#else
typedef unsigned long long Elf64_Addr;
typedef unsigned long long Elf64_Off;
typedef unsigned long long Elf64_Xword;
typedef long long Elf64_Sxword;
#endif
typedef unsigned short Elf64_Half;
typedef int Elf64_Sword;
typedef unsigned int Elf64_Word;
typedef unsigned char Elf64_Byte; /* Unsigned tiny integer */
#ifdef __cplusplus
}
#endif
#endif /* ELFTYPES_INCLUDED */
This diff is collapsed.
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenAirInterface is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/*
C Header file <updatefw.h> for updatefw tool.
K. Khalfallah, Aug, 2007
kkhalfallah@free.fr
*/
#ifndef UPDATEFW_H
#define UPDATEFW_H
#include <stdio.h>
#include <errno.h>
#define _testsyscall(x, y, z) {if (x==-1) { \
fprintf(stderr, "Error : %s() returned "z" (errno=%d)\n", y, x, errno); \
fprintf(stderr, "Warning : not leaving normally. Remove ipc ressources by hand !"); \
fprintf(stderr, " (use shell commands ipcs & ipcrm)\n"); \
exit(-1); \
}}
// else { \
// printf("Info : successfully called %s, returned "z"\n", y, x);}}
/* Intel is little-endian, sparc is big */
unsigned long ltmp;
#define invert4(x) {ltmp=x; x=((ltmp & 0xff)<<24) | ((ltmp & 0xff00)<<8) | \
((ltmp & 0xff0000)>>8) | ((ltmp & 0xff000000)>>24); }
unsigned short stmp;
#define invert2(x) {stmp=x; x=((stmp & 0xff)<< 8) | ((stmp & 0xff00)>>8);}
/* static variables, global */
char* virt_addr;
unsigned int packet_ndx = 0;
#define FSEEK_ORIGIN 0
#define FSEEK_CURRENT 1
#define READ_FILE_MODE "r"
/* Verbose levels */
#define VERBOSE_LEVEL_MAIN_STEPS 1
#define VERBOSE_LEVEL_ACCESS_FILES 2
#define VERBOSE_LEVEL_SECTION_DETAILS 3
#define VERBOSE_LEVEL_IOCTL 4
#endif /* UPDATEFW_H */
function [ratio,phi_est]=IQ_estimation(freq)
gpib_card=0; % first GPIB PCI card in the computer
sme=28; % this is configured in the signal generator Utilities->System->GPIB->Address menu (for SME)
gpib_send(gpib_card,sme,'*RST;*CLS'); % reset and configure the signal generator
sleep(.1);
gpib_send(gpib_card,sme,'POW -63dBm');
disp(freq)
gpib_send(gpib_card,sme,strcat('FREQ ',int2str(freq),'MHz'));
gpib_send(gpib_card,sme,'OUTP:STAT ON'); % activate output
cmd1='/homes/nussbaum/openair1/ARCH/LEON3/hostpc/user/tools/scripts/set_receiver -M ';
gain1=61;
gain2=61;
frequency=int2str(freq);
cmd=strcat(cmd1,frequency,' -g1 ',int2str(gain1),' -g2 ',int2str(gain2));
system(cmd);
sleep(.1);
s=oarf_get_frame(0);
signal=s(:,1);
size_data=20480;
Fs=7680; %in kHz
band = 2000; %in kHz
max_pos=0;
max=0;
f=abs(fft(signal)).^2;
for n=2:size_data
if(f(n) > max)
max=f(n);
max_pos=n;
end;
end;
disp(max_pos)
freq_max=Fs/size_data*max_pos - Fs/2 % corresponding frequency
if(abs(freq_max-2000)>100)
disp('Warning')
end;
cumI=0;
cumQ=0;
I=real(signal(1:2000));
Q=imag(signal(1:2000));
for i=1:2000
cumI=cumI + I(i)*I(i);
cumQ=cumQ + Q(i)*Q(i);
end;
amp= sqrt(2*cumI/length(I))
I=I/amp;
Q=Q/amp;
ratio=sqrt(cumI/cumQ)
n_fft=1024;
f=abs(fft(I(1:n_fft)));
max = 0;
index=0;
for i=1:n_fft/2
if f(i)> max
max=f(i);
index=i;
end;
end;
disp(max)
disp(index)
%figure
%plot(20*log10(abs(f)));
freq_estim=(index-1)/n_fft;
p=Q*ratio.*I;
sinphi=2*sum(p)/length(Q);
phi_est=-asin(sinphi)
Qcor=(sin(phi_est)*I+ratio*Q)/cos(phi_est);
%figure
%plot(I(1:100))
%hold on
%plot(Qcor(1:100),'g');
comp=I+j*Qcor;
%hold off
%figure
%plot(20*log10(abs(fft(comp))));
endfunction;
% per=round(1/freq_estim)
% figure;plot(I(1:per+1))
% opt_offset=-5
% min_diff=10^20;
% for offset=0:per
% diff=0;
% for k=1:n_fft
% diff=diff+abs(I(k+offset)-Q(k));
% end;
% if diff<min_diff
% min_diff=diff;
% opt_offset= offset;
% end;
% end;
% disp(opt_offset)
% % normally, as to be 3/4*per
% opt_offset=opt_offset-3*per/4;
% disp(opt_offset/per*2*pi)
s = oarf_get_frame(2);
sig0 = s(:,1);
sig1 = s(:,2);
sig0 = s(5000:end,1); % first channel
sig1 = s(5000:end,2); % 2nd channel
bw=7.68e6;
spec = abs(fft(sig1)).^2;
[a,b] = max(spec);
freq = (b-1)*bw/length(sig0);
L= 1000;
W = 1;
offset_vec = (0:L-1)*((2*W)+1);
W2 = 1+(2*W);
window_vec = (-W : W);
pn = zeros(1,(2*L) - 1);
for i = 1:L,
pn(i+L-1) = sum(spec(offset_vec(i) + b + window_vec));
end
for i = 2:L,
pn(L-i+1) = sum(spec(-offset_vec(i) + b + window_vec));
end
pn_2 = 20*log10(pn / pn(L)) - 10*log10(W2*bw/length(sig0));
f = ((-L+1):(L-1))*W2*bw/length(sig0);
ylabel('dBc/Hz')
xlabel("f_offset (Hz)")
title("Phase Noise @ IQ output for Fc = 1912.6 + Fs/4 MHz CW input at antenna")
semilogx(f(L:(2*L - 1)),pn_2(L:(2*L -1)))
sum(pn.^2*(f(2)-f(1)))
closeplot
figure(1)
gain2391=70; gain9862=0;
for rxrfmode=0:2
i=find( (m(:,2)==gain2391) & (m(:,3)==gain9862) & (m(:,4)==rxrfmode));
plot(m(i,1),m(i,5:8))
pause
end
gain2391=70; rxrfmode=1;
for gain9862=0:5:15
i=find((m(:,2)==gain2391) & (m(:,3)==gain9862) & (m(:,4)==rxrfmode));
plot(m(i,1),m(i,5:8))
pause
end
rxrfmode=1; power_dBm=-70;
i=find((m(:,1)==power_dBm) & (m(:,4)==rxrfmode));
plot(m(i,1),m(i,5:8))
pause
end
power_dBm=-90;
subplot(1,3,1)
rxrfmode=0;
i=find((m(:,1)==power_dBm) & (m(:,4)==rxrfmode));
mesh(0:10:150,[0 5 10 15],reshape(m(i,5)-m(i,6),4,16))
subplot(1,3,2)
rxrfmode=1;
i=find((m(:,1)==power_dBm) & (m(:,4)==rxrfmode));
mesh(0:10:150,[0 5 10 15],reshape(m(i,5)-m(i,6),4,16))
subplot(1,3,3)
rxrfmode=2;
i=find((m(:,1)==power_dBm) & (m(:,4)==rxrfmode));
mesh(0:10:150,[0 5 10 15],reshape(m(i,5)-m(i,6),4,16))
closeplot
figure(1);
%for power_dBm=ALL_power_dBm
for power_dBm=-65
disp(['input: ' num2str(power_dBm) ' dBm']);
xlabel('Gain 2391');
ylabel('Gain 9862');
zlabel('SNR');
rxrfmode=0;
idx=find((m(:,1)==power_dBm) & (m(:,4)==rxrfmode));
M0=zeros(length(ALL_gain2391),length(ALL_gain9862));
M1=zeros(length(ALL_gain2391),length(ALL_gain9862));
for i=idx.'
i1=find(ALL_gain2391==m(i,2));
i2=find(ALL_gain9862==m(i,3));
M0(i1,i2)=m(i,5)-m(i,6);
M1(i1,i2)=m(i,7)-m(i,8);
end
subplot(2,3,1); clg;
title('Channel 0, rxrfmode 0');
mesh(ALL_gain2391,ALL_gain9862,M0.')
subplot(2,3,4); clg;
title('Channel 1, rxrfmode 0');
mesh(ALL_gain2391,ALL_gain9862,M1.')
rxrfmode=1;
idx=find((m(:,1)==power_dBm) & (m(:,4)==rxrfmode));
M0=zeros(length(ALL_gain2391),length(ALL_gain9862));
M1=zeros(length(ALL_gain2391),length(ALL_gain9862));
for i=idx.'
i1=find(ALL_gain2391==m(i,2));
i2=find(ALL_gain9862==m(i,3));
M0(i1,i2)=m(i,5)-m(i,6);
M1(i1,i2)=m(i,7)-m(i,8);
end
subplot(2,3,2); clg;
title('Channel 0, rxrfmode 1');
mesh(ALL_gain2391,ALL_gain9862,M0.')
subplot(2,3,5); clg;
title('Channel 1, rxrfmode 1');
mesh(ALL_gain2391,ALL_gain9862,M1.')
rxrfmode=2;
idx=find((m(:,1)==power_dBm) & (m(:,4)==rxrfmode));
M0=zeros(length(ALL_gain2391),length(ALL_gain9862));
M1=zeros(length(ALL_gain2391),length(ALL_gain9862));
for i=idx.'
i1=find(ALL_gain2391==m(i,2));
i2=find(ALL_gain9862==m(i,3));
M0(i1,i2)=m(i,5)-m(i,6);
M1(i1,i2)=m(i,7)-m(i,8);
end
subplot(2,3,3); clg;
title('Channel 0, rxrfmode 2');
mesh(ALL_gain2391,ALL_gain9862,M0.')
subplot(2,3,6); clg;
title('Channel 1, rxrfmode 2');
mesh(ALL_gain2391,ALL_gain9862,M1.')
pause
end
%frequency = input('Input freq in MHz: ', 's');
% script to setup mxa and sign generator
size_data=20480;
Fs=7680; %sampling freq in kHz
band = 2500; % noise band in kHz
gpib_card=0; % first GPIB PCI card in the computer
sme=28; % this is configured in the signal generator Utilities->System->GPIB->Address menu (for SME)
openair_init;
freq=2000; % normally loop
% first, calculation of IQ missmatch
[ratio,phase]=IQ_estimation(freq);
gpib_send(gpib_card,sme,'*RST;*CLS'); % reset and configure the signal generator
gpib_send(gpib_card,sme,'POW -100dBm');
%disp('FREQ ',int2str(freq),'MHz');
gpib_send(gpib_card,sme,strcat('FREQ ',int2str(freq),'MHz'));
%disp('FREQ ',int2str(freq),'MHz');
%frequency = input('Input freq in MHz: ', 's');
cmd1='/homes/nussbaum/open_freya/arch/openair_CardBus_MIMO1/LEON3/hostpc/user/tools/scripts/set_receiver -M ';
frequency=int2str(freq);
ALL_gain1=0:16:3;
ALL_gain2=0:16:3;
i=0;
for gain1=ALL_gain1
for gain2= ALL_gain2
i=i+1;
end;
end;
table=zeros(i,4);
i=1;
for gain1=ALL_gain1
for gain2=ALL_gain2
cmd=strcat(cmd1,frequency,' -g1 ',int2str(gain1),' -g2 ',int2str(gain2));
system(cmd);
%system('set_receiver -M ' frequency ' -g1 ' int2str(gain1) ' -g2 ' int2str(gain2));
%system('sleep 1');
gpib_send(gpib_card,sme,'OUTP:STAT ON'); % activate output
sleep(.1);
table(i,1)=gain1;
table(i,2)=gain2;
s=oarf_get_frame(0);
plot(20*log10(abs(fft(s(:,1)))))
signal=s(:,1);
max_pos=0;
max=0;
f=abs(fft(signal)).^2;
for n=2:size_data
if(f(n) > max)
max=f(n);
max_pos=n;
end;
end;
disp(max_pos)
freq_max=Fs/size_data*max_pos - Fs/2 % corresponding frequency
if(abs(freq_max-2000)>100)
disp("Warning")
end;
% calculation of the signal power
Pu=sum(f(max_pos-20:max_pos+20))
ns_noise =round((band/Fs)*(size_data/2))
Pnoise=sum(f(max_pos-ns_noise:max_pos+ns_noise))-Pu
plot(10*log10(f))
% plot(10*log10(f(max_pos-ns_noise:max_pos+ns_noise)))
SNR=10*log10(Pu/Pnoise)
N_in = -174 +10*log10(1000*band)
S_in = -100;
SNR_in=S_in - N_in
NF=SNR_in-SNR
i=i+1;
end;
end;
disp(table);
P_num =100; %(warning, to be updated)
% Post processing of the table started here
Pmin = -40; % in dBm
Pmax = 20; % in dBm
% a Tx calibration file is calculated for a given board and frequency
%fid=fopen(['/tmp/cal_TX' frequency '_' int2str(n) '.dat'],'wb')
%fwrite(fid,signal);
%fclose(fid);
% Maxime Guillaud - created Wed May 10 18:08:04 CEST 2006
gpib_card=0; % first GPIB PCI card in the computer
gpib_device=28; % this is configured in the signal generator Utilities->System->GPIB->Address menu
freqband=2; % frequency band used by the openair card
cables_loss_dB = 6; % we need to account for the power loss between the signal generator and the card input (splitter, cables)
gpib_send(gpib_card,gpib_device,'*RST;*CLS'); % reset and configure the signal generator
gpib_send(gpib_card,gpib_device,'POW -70dBm');
gpib_send(gpib_card,gpib_device,'FREQ 1.91452GHz');
oarf_config(freqband,'openair_config.cfg','openair_scenario.scn')
saturation_threshold =5; % min number of samples (real+imaginary) equal to the max per frame to declare saturation
ALL_power_dBm = [-100:1:-60 -150];
ALL_rxrfmode = 0:2;
ALL_gain2391 = 0:5:120; % this is some strange scale
ALL_gain9862 = 0:1:18; % this in in dB
m=[];
%for power_dBm=ALL_power_dBm
power_dBm=-70
gpib_send(gpib_card,gpib_device,['POW ' int2str(power_dBm+cables_loss_dB) 'dBm']);
sleep(1)
for gain9862=ALL_gain9862
for gain2391= ALL_gain2391
gpib_send(gpib_card,gpib_device,'OUTP:STAT ON'); % activate output
oarf_set_rx_gain(gain2391,gain9862,gain2391,gain9862);
nacq=0; % count the number of tries to get data
do
s=oarf_get_frame(freqband); %oarf_get_frame
sleep(.1);
nacq=nacq+1;
until max(max(abs(s)))>0 % ensures that the frame is properly read
for gain9862=ALL_gain9862
for gain2391= ALL_gain2391
SpN0 = mean(abs(s(:,1)).^2) - abs(mean(s(:,1))).^2;
SpN1 = mean(abs(s(:,2)).^2) - abs(mean(s(:,2))).^2;
gpib_send(gpib_card,gpib_device,'OUTP:STAT OFF'); % deactivate output
oarf_set_rx_gain(gain2391,gain9862,gain2391,gain9862);
nacq=0; % count the number of tries to get data
do
sleep(.1);
s=oarf_get_frame(freqband);
nacq=nacq+1;
until max(max(abs(s)))>0 % ensures that the frame is properly read
N0 = mean(abs(s(:,1)).^2) - abs(mean(s(:,1))).^2;
N1 = mean(abs(s(:,2)).^2) - abs(mean(s(:,2))).^2;
<<<<<<< rx_calibration.m
S0 = 10*log10(SpN0-N0);
S1 = 10*log10(SpN1-N1);
G0 = S0 - power_dBm;
G1 = S1 - power_dBm;
NF0 = N0 - G0 + 108;
NF1 = N1 - G1 + 108;
fprintf(' %d %d : Signal strength (%d,%d), Gain (%d %d), NF (%d %d)\n',
gain2391,gain9862, S0,S1,G0,G1,NF0,NF1);
end
end